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

Unified Diff: net/ftp/ftp_network_transaction.cc

Issue 160537: Correctly handle multiple control responses for RETR command. (Closed)
Patch Set: Created 11 years, 5 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 | « net/ftp/ftp_ctrl_response_buffer.cc ('k') | 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 95025e7184936bfd5456b8424a76c5060f1d05e2..8d90e8f3e4ab6821c8bf39eb1bbc9a45f04f24f4 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -110,6 +110,11 @@ uint64 FtpNetworkTransaction::GetUploadProgress() const {
// Used to prepare and send FTP commad.
int FtpNetworkTransaction::SendFtpCommand(const std::string& command,
Command cmd) {
+ // If we send a new command when we still have unprocessed responses
+ // for previous commands, the response receiving code will have no way to know
+ // which responses are for which command.
+ DCHECK(!ctrl_response_buffer_.ResponseAvailable());
+
DCHECK(!write_command_buf_);
DCHECK(!write_buf_);
DLOG(INFO) << " >> " << command;
@@ -129,12 +134,6 @@ int FtpNetworkTransaction::SendFtpCommand(const std::string& command,
int FtpNetworkTransaction::ProcessCtrlResponse() {
FtpCtrlResponse response = ctrl_response_buffer_.PopResponse();
wtc 2009/08/04 23:46:30 Should this function empty ctrl_response_buffer_ b
- // TODO(phajdan.jr): Remove when http://crbug.com/18036 is diagnosed.
- DLOG(INFO) << "Consumed one control response.";
-
- // We always expect only one response, even if it's multiline.
- DCHECK(!ctrl_response_buffer_.ResponseAvailable());
-
int rv = OK;
switch (command_sent_) {
case COMMAND_NONE:
@@ -184,6 +183,22 @@ int FtpNetworkTransaction::ProcessCtrlResponse() {
DLOG(INFO) << "Missing Command response handling!";
return ERR_FAILED;
}
+
+ // We may get multiple responses for some commands,
+ // see http://crbug.com/18036.
+ while (ctrl_response_buffer_.ResponseAvailable() && rv == OK) {
+ response = ctrl_response_buffer_.PopResponse();
+
+ switch (command_sent_) {
+ case COMMAND_RETR:
+ rv = ProcessResponseRETR(response);
+ break;
+ default:
+ // Multiple responses for other commands are invalid.
+ return ERR_INVALID_RESPONSE;
+ }
+ }
+
return rv;
}
@@ -725,6 +740,7 @@ int FtpNetworkTransaction::ProcessResponseRETR(
const FtpCtrlResponse& response) {
switch (GetErrorClass(response.status_code)) {
case ERROR_CLASS_INITIATED:
+ next_state_ = STATE_CTRL_READ;
break;
case ERROR_CLASS_OK:
next_state_ = STATE_CTRL_WRITE_QUIT;
« no previous file with comments | « net/ftp/ftp_ctrl_response_buffer.cc ('k') | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698