| OLD | NEW |
| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 default: | 217 default: |
| 218 CleanupConnection(); | 218 CleanupConnection(); |
| 219 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, | 219 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, |
| 220 WinInetUtil::OSErrorToNetError(result.dwError))); | 220 WinInetUtil::OSErrorToNetError(result.dwError))); |
| 221 return; | 221 return; |
| 222 } | 222 } |
| 223 } else if (state_ == SETTING_CUR_DIRECTORY) { | 223 } else if (state_ == SETTING_CUR_DIRECTORY) { |
| 224 OnSetCurrentDirectory(result.dwError); | 224 OnSetCurrentDirectory(result.dwError); |
| 225 } else if (state_ == FINDING_FIRST_FILE) { | 225 } else if (state_ == FINDING_FIRST_FILE) { |
| 226 if (result.dwError != ERROR_SUCCESS) { | 226 // We don't fail here if result.dwError != ERROR_SUCCESS because |
| 227 // getting an error here doesn't always mean the file is not found. |
| 228 // FindFirstFileA() issue a LIST command and may fail on some |
| 229 // ftp server when the requested object is a file. So ERROR_NO_MORE_FILES |
| 230 // from FindFirstFileA() is not a reliable criteria for valid path |
| 231 // or not, we should proceed optimistically by getting the file handle. |
| 232 if (result.dwError != ERROR_SUCCESS && |
| 233 result.dwError != ERROR_NO_MORE_FILES) { |
| 227 DWORD result_error = result.dwError; | 234 DWORD result_error = result.dwError; |
| 228 CleanupConnection(); | 235 CleanupConnection(); |
| 229 // Fixup the error message from our directory/file guessing. | |
| 230 if (!is_directory_ && result_error == ERROR_NO_MORE_FILES) | |
| 231 result_error = ERROR_PATH_NOT_FOUND; | |
| 232 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, | 236 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, |
| 233 WinInetUtil::OSErrorToNetError(result_error))); | 237 WinInetUtil::OSErrorToNetError(result_error))); |
| 234 return; | 238 return; |
| 235 } | 239 } |
| 236 request_handle_ = (HINTERNET)result.dwResult; | 240 request_handle_ = (HINTERNET)result.dwResult; |
| 237 OnFindFirstFile(result.dwError); | 241 OnFindFirstFile(result.dwError); |
| 238 } else if (state_ == GETTING_DIRECTORY) { | 242 } else if (state_ == GETTING_DIRECTORY) { |
| 239 OnFindFile(result.dwError); | 243 OnFindFile(result.dwError); |
| 240 } else if (state_ == GETTING_FILE_HANDLE) { | 244 } else if (state_ == GETTING_FILE_HANDLE) { |
| 241 if (result.dwError != ERROR_SUCCESS) { | 245 if (result.dwError != ERROR_SUCCESS) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 523 |
| 520 *location = request_->url().ReplaceComponents(replacements); | 524 *location = request_->url().ReplaceComponents(replacements); |
| 521 *http_status_code = 301; // simulate a permanent redirect | 525 *http_status_code = 301; // simulate a permanent redirect |
| 522 return true; | 526 return true; |
| 523 } | 527 } |
| 524 } | 528 } |
| 525 | 529 |
| 526 return false; | 530 return false; |
| 527 } | 531 } |
| 528 | 532 |
| OLD | NEW |