summaryrefslogtreecommitdiffstats
path: root/net/http/http_stream_parser.cc
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 20:44:21 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 20:44:21 +0000
commit4750937f28e4646c8ffaa063913f104fee29ad13 (patch)
tree507e1fe63f1a48c79a22e331955d129f79d1557f /net/http/http_stream_parser.cc
parent683e08b6585ff4f98332a69660a7dd85047ae203 (diff)
downloadchromium_src-4750937f28e4646c8ffaa063913f104fee29ad13.zip
chromium_src-4750937f28e4646c8ffaa063913f104fee29ad13.tar.gz
chromium_src-4750937f28e4646c8ffaa063913f104fee29ad13.tar.bz2
Do not enqueue multiple socket writes performing an HTTP chunked request
When performing an HTTP request that uses a chunked transfer encoding, and both the underlying socket and the UploadDataStream provide data asynchronously, ensure that writes to the underlying socket maintain a strict ordering and that only one callback (socket write, chunked data available) is pending at a time. BUG=132243 TEST=HttpStreamParser.AsyncChunkAndAsyncSocket Review URL: https://chromiumcodereview.appspot.com/10536138 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_stream_parser.cc')
-rw-r--r--net/http/http_stream_parser.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index d368f90..cb5cb11 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -347,9 +347,10 @@ void HttpStreamParser::OnChunkAvailable() {
// headers, we will automatically start reading the chunks once we get into
// STATE_SENDING_CHUNKED_BODY so nothing to do here.
DCHECK(io_state_ == STATE_SENDING_HEADERS ||
- io_state_ == STATE_SENDING_CHUNKED_BODY);
- if (io_state_ == STATE_SENDING_CHUNKED_BODY)
- OnIOComplete(0);
+ io_state_ == STATE_SENDING_CHUNKED_BODY ||
+ io_state_ == STATE_SEND_REQUEST_WAIT_FOR_BODY_CHUNK_COMPLETE);
+ if (io_state_ == STATE_SEND_REQUEST_WAIT_FOR_BODY_CHUNK_COMPLETE)
+ OnIOComplete(OK);
}
int HttpStreamParser::DoLoop(int result) {
@@ -374,6 +375,9 @@ int HttpStreamParser::DoLoop(int result) {
else
result = DoSendNonChunkedBody(result);
break;
+ case STATE_SEND_REQUEST_WAIT_FOR_BODY_CHUNK_COMPLETE:
+ result = DoSendRequestWaitForBodyChunkComplete(result);
+ break;
case STATE_REQUEST_SENT:
DCHECK(result != ERR_IO_PENDING);
can_do_more = false;
@@ -473,7 +477,8 @@ int HttpStreamParser::DoSendChunkedBody(int result) {
request_body_buf_->capacity());
request_body_buf_->DidAppend(chunk_length);
} else if (consumed == ERR_IO_PENDING) {
- // Nothing to send. More POST data is yet to come.
+ // Nothing to send. More request data is yet to come.
+ io_state_ = STATE_SEND_REQUEST_WAIT_FOR_BODY_CHUNK_COMPLETE;
return ERR_IO_PENDING;
} else {
// There won't be other errors.
@@ -514,6 +519,18 @@ int HttpStreamParser::DoSendNonChunkedBody(int result) {
return result;
}
+int HttpStreamParser::DoSendRequestWaitForBodyChunkComplete(int result) {
+ if (result != OK) {
+ io_state_ = STATE_DONE;
+ return result;
+ }
+ // Sending the chunked body was paused while waiting for more chunks to
+ // be available. Resume sending chunks now that one or more chunks have
+ // arrived.
+ io_state_ = STATE_SENDING_CHUNKED_BODY;
+ return OK;
+}
+
int HttpStreamParser::DoReadHeaders() {
io_state_ = STATE_READ_HEADERS_COMPLETE;