Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: net/url_request/url_request_ftp_job.cc

Issue 201083: Cache login identity for NewFTP transactions. (Closed)
Patch Set: better Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_ftp_job.h" 5 #include "net/url_request/url_request_ftp_job.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <wininet.h> 8 #include <wininet.h>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // latest input rather than always trying what they specified 131 // latest input rather than always trying what they specified
132 // in the url (if anything). 132 // in the url (if anything).
133 string username, password; 133 string username, password;
134 bool have_auth = false; 134 bool have_auth = false;
135 if (server_auth_ && server_auth_->state == net::AUTH_STATE_HAVE_AUTH) { 135 if (server_auth_ && server_auth_->state == net::AUTH_STATE_HAVE_AUTH) {
136 // Add auth info to cache 136 // Add auth info to cache
137 have_auth = true; 137 have_auth = true;
138 username = WideToUTF8(server_auth_->username); 138 username = WideToUTF8(server_auth_->username);
139 password = WideToUTF8(server_auth_->password); 139 password = WideToUTF8(server_auth_->password);
140 request_->context()->ftp_auth_cache()->Add(request_->url().GetOrigin(), 140 request_->context()->ftp_auth_cache()->Add(request_->url().GetOrigin(),
141 server_auth_.get()); 141 server_auth_->username,
142 server_auth_->password);
142 } else { 143 } else {
143 if (request_->url().has_username()) { 144 if (request_->url().has_username()) {
144 username = request_->url().username(); 145 username = request_->url().username();
145 password = request_->url().has_password() ? request_->url().password() : 146 password = request_->url().has_password() ? request_->url().password() :
146 ""; 147 "";
147 have_auth = true; 148 have_auth = true;
148 } 149 }
149 } 150 }
150 151
151 int port = request_->url().has_port() ? 152 int port = request_->url().has_port() ?
(...skipping 24 matching lines...) Expand all
176 OnFinishDirectoryTraversal(); 177 OnFinishDirectoryTraversal();
177 return; 178 return;
178 case ERROR_INTERNET_LOGIN_FAILURE: 179 case ERROR_INTERNET_LOGIN_FAILURE:
179 // fall through 180 // fall through
180 case ERROR_INTERNET_INCORRECT_USER_NAME: 181 case ERROR_INTERNET_INCORRECT_USER_NAME:
181 // fall through 182 // fall through
182 case ERROR_INTERNET_INCORRECT_PASSWORD: { 183 case ERROR_INTERNET_INCORRECT_PASSWORD: {
183 GURL origin = request_->url().GetOrigin(); 184 GURL origin = request_->url().GetOrigin();
184 if (server_auth_ != NULL && 185 if (server_auth_ != NULL &&
185 server_auth_->state == net::AUTH_STATE_HAVE_AUTH) { 186 server_auth_->state == net::AUTH_STATE_HAVE_AUTH) {
186 request_->context()->ftp_auth_cache()->Remove(origin); 187 request_->context()->ftp_auth_cache()->Remove(origin,
188 server_auth_->username,
189 server_auth_->password);
187 } else { 190 } else {
188 server_auth_ = new net::AuthData(); 191 server_auth_ = new net::AuthData();
189 } 192 }
190 server_auth_->state = net::AUTH_STATE_NEED_AUTH; 193 server_auth_->state = net::AUTH_STATE_NEED_AUTH;
191 194
192 scoped_refptr<net::AuthData> cached_auth = 195 net::FtpAuthCache::Entry* cached_auth =
193 request_->context()->ftp_auth_cache()->Lookup(origin); 196 request_->context()->ftp_auth_cache()->Lookup(origin);
194 197
195 if (cached_auth) { 198 if (cached_auth) {
196 // Retry using cached auth data. 199 // Retry using cached auth data.
197 SetAuth(cached_auth->username, cached_auth->password); 200 SetAuth(cached_auth->username, cached_auth->password);
198 } else { 201 } else {
199 // The io completed fine, the error was due to invalid auth. 202 // The io completed fine, the error was due to invalid auth.
200 SetStatus(URLRequestStatus()); 203 SetStatus(URLRequestStatus());
201 204
202 // Prompt for a username/password. 205 // Prompt for a username/password.
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 replacements.SetPathStr(ftp_path); 553 replacements.SetPathStr(ftp_path);
551 554
552 *location = request_->url().ReplaceComponents(replacements); 555 *location = request_->url().ReplaceComponents(replacements);
553 *http_status_code = 301; // simulate a permanent redirect 556 *http_status_code = 301; // simulate a permanent redirect
554 return true; 557 return true;
555 } 558 }
556 } 559 }
557 560
558 return false; 561 return false;
559 } 562 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698