Index: net/ftp/ftp_network_transaction.cc |
=================================================================== |
--- net/ftp/ftp_network_transaction.cc (revision 19238) |
+++ net/ftp/ftp_network_transaction.cc (working copy) |
@@ -88,22 +88,15 @@ |
DCHECK(buf); |
DCHECK(buf_len > 0); |
- if (data_socket_ == NULL) |
- return 0; // Data socket closed, no more data left. |
- |
- if (!data_socket_->IsConnected()) |
- return 0; // Data socket disconnected, no more data left. |
- |
read_data_buf_ = buf; |
- read_data_buf_len_ = buf_len; |
- |
+ // Always read one byte less than the size, because if data is directory |
+ // listing then we must have a null terminating string. |
+ read_data_buf_len_ = buf_len - 1; |
next_state_ = STATE_DATA_READ; |
int rv = DoLoop(OK); |
if (rv == ERR_IO_PENDING) |
user_callback_ = callback; |
- else if (rv == 0) |
- data_socket_->Disconnect(); |
return rv; |
} |
@@ -795,8 +788,8 @@ |
int FtpNetworkTransaction::ProcessResponseLIST(int response_code) { |
switch (GetErrorClass(response_code)) { |
case ERROR_CLASS_INITIATED: |
+ response_.is_directory_listing = true; |
response_message_buf_len_ = 0; // Clear the responce buffer. |
- next_state_ = STATE_CTRL_READ; |
break; |
case ERROR_CLASS_OK: |
response_.is_directory_listing = true; |
@@ -865,6 +858,9 @@ |
} |
int FtpNetworkTransaction::DoDataRead() { |
+ if (data_socket_ == NULL || !data_socket_->IsConnected()) |
+ return Stop(OK); // No more data so send QUIT Command now and wait for response. |
+ |
DCHECK(read_data_buf_); |
DCHECK(read_data_buf_len_ > 0); |
@@ -875,8 +871,6 @@ |
} |
int FtpNetworkTransaction::DoDataReadComplete(int result) { |
- DLOG(INFO) << read_data_buf_->data(); // The read_data_buf_ is NULL |
- // terminated string. |
return result; |
} |