Index: net/http/http_stream_parser.cc |
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc |
index b85a342dda979f2bb178024d63ebd18535217112..34f48d8840f5d34db2d8e8c4d91b2756bdddc8e3 100644 |
--- a/net/http/http_stream_parser.cc |
+++ b/net/http/http_stream_parser.cc |
@@ -128,10 +128,10 @@ int HttpStreamParser::SendRequest(const std::string& request_line, |
request_body_.reset(request_body); |
if (request_body_ != NULL && request_body_->is_chunked()) { |
request_body_->set_chunk_callback(this); |
- // The raw chunk buffer is guaranteed to be large enough to hold the |
- // encoded chunk. |
- raw_chunk_buf_ = new IOBufferWithSize(UploadDataStream::GetBufferSize() + |
- kChunkHeaderFooterSize); |
+ // The chunk buffer is guaranteed to be large enough to hold the encoded |
+ // chunk. |
+ chunk_buf_ = new SeekableIOBuffer(UploadDataStream::GetBufferSize() + |
+ kChunkHeaderFooterSize); |
} |
io_state_ = STATE_SENDING_HEADERS; |
@@ -349,7 +349,7 @@ int HttpStreamParser::DoSendChunkedBody(int result) { |
// DoSendChunkedBody(), or 0 (i.e. OK) the first time. |
// Send the remaining data in the chunk buffer. |
- if (chunk_buf_.get()) { |
+ if (result > 0) { |
wtc
2012/02/02 20:22:57
Nit: it is safe to call
chunk_buf_->DidConsume(
satorux1
2012/02/02 22:02:27
Good point. Done.
|
chunk_buf_->DidConsume(result); |
if (chunk_buf_->BytesRemaining() > 0) { |
return connection_->socket()->Write(chunk_buf_, |
@@ -369,17 +369,19 @@ int HttpStreamParser::DoSendChunkedBody(int result) { |
chunk_length_without_encoding_ = 0; |
if (request_body_->eof()) { |
+ chunk_buf_->Clear(); |
const int chunk_length = EncodeChunk( |
- base::StringPiece(), raw_chunk_buf_->data(), raw_chunk_buf_->size()); |
- chunk_buf_ = new DrainableIOBuffer(raw_chunk_buf_, chunk_length); |
+ base::StringPiece(), chunk_buf_->data(), chunk_buf_->capacity()); |
+ chunk_buf_->DidAppend(chunk_length); |
sent_last_chunk_ = true; |
} else if (request_body_->buf_len() > 0) { |
// Encode and send the buffer as 1 chunk. |
const base::StringPiece payload(request_body_->buf()->data(), |
request_body_->buf_len()); |
+ chunk_buf_->Clear(); |
const int chunk_length = EncodeChunk( |
- payload, raw_chunk_buf_->data(), raw_chunk_buf_->size()); |
- chunk_buf_ = new DrainableIOBuffer(raw_chunk_buf_, chunk_length); |
+ payload, chunk_buf_->data(), chunk_buf_->capacity()); |
+ chunk_buf_->DidAppend(chunk_length); |
chunk_length_without_encoding_ = payload.size(); |
} else { |
// Nothing to send. More POST data is yet to come? |