summaryrefslogtreecommitdiffstats
path: root/net/ftp/ftp_ctrl_response_buffer.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 23:35:24 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 23:35:24 +0000
commit04d4d5433e517210c77fcd0bccaba76a0de57e66 (patch)
treee886796bef543f6646177d2c55512847438cdc2d /net/ftp/ftp_ctrl_response_buffer.cc
parent003b2fbb1211d59b89aea7961b675aea5ba56942 (diff)
downloadchromium_src-04d4d5433e517210c77fcd0bccaba76a0de57e66.zip
chromium_src-04d4d5433e517210c77fcd0bccaba76a0de57e66.tar.gz
chromium_src-04d4d5433e517210c77fcd0bccaba76a0de57e66.tar.bz2
Followup after http://codereview.chromium.org/149368
Fix minor issues in new ftp code. TEST=none BUG=none Review URL: http://codereview.chromium.org/160541 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_ctrl_response_buffer.cc')
-rw-r--r--net/ftp/ftp_ctrl_response_buffer.cc10
1 files changed, 3 insertions, 7 deletions
diff --git a/net/ftp/ftp_ctrl_response_buffer.cc b/net/ftp/ftp_ctrl_response_buffer.cc
index 02f9908..9441f4b 100644
--- a/net/ftp/ftp_ctrl_response_buffer.cc
+++ b/net/ftp/ftp_ctrl_response_buffer.cc
@@ -27,7 +27,7 @@ namespace net {
const int FtpCtrlResponse::kInvalidStatusCode = -1;
int FtpCtrlResponseBuffer::ConsumeData(const char* data, int data_length) {
- buffer_.append(std::string(data, data_length));
+ buffer_.append(data, data_length);
ExtractFullLinesFromBuffer();
while (!lines_.empty()) {
@@ -38,11 +38,10 @@ int FtpCtrlResponseBuffer::ConsumeData(const char* data, int data_length) {
if (!line.is_complete)
return ERR_INVALID_RESPONSE;
+ response_buf_.status_code = line.status_code;
if (line.is_multiline) {
line_buf_ = line.status_text;
- response_buf_.status_code = line.status_code;
} else {
- response_buf_.status_code = line.status_code;
response_buf_.lines.push_back(line.status_text);
LogResponse(response_buf_);
responses_.push(response_buf_);
@@ -106,14 +105,11 @@ FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine(
}
void FtpCtrlResponseBuffer::ExtractFullLinesFromBuffer() {
- std::string line_buf;
int cut_pos = 0;
for (size_t i = 0; i < buffer_.length(); i++) {
- line_buf.push_back(buffer_[i]);
if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') {
- lines_.push(ParseLine(line_buf.substr(0, line_buf.length() - 2)));
+ lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1)));
cut_pos = i + 1;
- line_buf.clear();
}
}
buffer_.erase(0, cut_pos);