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

Unified Diff: net/ftp/ftp_network_transaction.cc

Issue 197050: Return ERR_FILE_NOT_FOUND from FtpNetworkTransaction when we can. (Closed)
Patch Set: clarify 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_network_transaction.cc
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index c5c9daf42787de5b79e86adeb4c17e9fa1df1a49..cf4a7738616c520d6ced66154b9560197059faa3 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -828,8 +828,12 @@ int FtpNetworkTransaction::ProcessResponseRETR(
return Stop(ERR_FAILED);
return ERR_FAILED; // TODO(ibrar): Retry here.
case ERROR_CLASS_PERMANENT_ERROR:
- if (retr_failed_)
+ // Code 550 means "Failed to open file". Other codes are unrelated,
+ // like "Not logged in" etc.
+ if (response.status_code != 550)
return Stop(ERR_FAILED);
+
+ DCHECK(!retr_failed_); // Should not get here twice.
retr_failed_ = true;
wtc 2009/09/09 18:41:31 My question is: are we going to try the CWD comman
next_state_ = STATE_CTRL_WRITE_PASV;
break;
@@ -901,6 +905,13 @@ int FtpNetworkTransaction::ProcessResponseCWD(const FtpCtrlResponse& response) {
case ERROR_CLASS_TRANSIENT_ERROR:
return Stop(ERR_FAILED);
case ERROR_CLASS_PERMANENT_ERROR:
+ if (retr_failed_ && response.status_code == 550) {
+ // Both RETR and CWD failed with codes 550. That means that the path
+ // we're trying to access is not a file, and not a directory. The most
+ // probable interpretation is that it doesn't exist (with FTP we can't
+ // be sure).
+ return Stop(ERR_FILE_NOT_FOUND);
+ }
return Stop(ERR_FAILED);
default:
NOTREACHED();
« no previous file with comments | « no previous file | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698