diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 17:53:22 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 17:53:22 +0000 |
commit | 0c9bf87fe0b87849105fc7a2ea16280e48ee9089 (patch) | |
tree | 8858b7c1f6c1071b2a0f93a92c72f08dcb0ad96d /net/spdy/spdy_http_stream.cc | |
parent | 27030d8d5d54002e1baaf19fefd909ebfb82de40 (diff) | |
download | chromium_src-0c9bf87fe0b87849105fc7a2ea16280e48ee9089.zip chromium_src-0c9bf87fe0b87849105fc7a2ea16280e48ee9089.tar.gz chromium_src-0c9bf87fe0b87849105fc7a2ea16280e48ee9089.tar.bz2 |
Add chunked uploads support to SPDY
As part of this, I had to move the chunked encoding part from UploadData::Element::SetChunk
to HttpStreamParser::DoSendBody as SPDY doesn't have this encoded format and UploadData
needs to serve both.
BUG=none
TEST=net_unittests (2 new tests added)
Committed and rolled back: http://src.chromium.org/viewvc/chrome?view=rev&revision=76892
Review URL: http://codereview.chromium.org/6292013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_http_stream.cc')
-rw-r--r-- | net/spdy/spdy_http_stream.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index e07578e..51a2efd 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -177,6 +177,11 @@ void SpdyHttpStream::SetConnectionReused() { // SPDY doesn't need an indicator here. } +void SpdyHttpStream::set_chunk_callback(ChunkCallback* callback) { + if (request_body_stream_ != NULL) + request_body_stream_->set_chunk_callback(callback); +} + int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers, UploadDataStream* request_body, HttpResponseInfo* response, @@ -200,7 +205,7 @@ int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers, CHECK(!request_body_stream_.get()); if (request_body) { - if (request_body->size()) + if (request_body->size() || request_body->is_chunked()) request_body_stream_.reset(request_body); else delete request_body; @@ -264,17 +269,33 @@ bool SpdyHttpStream::OnSendHeadersComplete(int status) { int SpdyHttpStream::OnSendBody() { CHECK(request_body_stream_.get()); + int buf_len = static_cast<int>(request_body_stream_->buf_len()); if (!buf_len) return OK; - return stream_->WriteStreamData(request_body_stream_->buf(), buf_len, - spdy::DATA_FLAG_FIN); + bool is_chunked = request_body_stream_->is_chunked(); + // TODO(satish): For non-chunked POST data, we set DATA_FLAG_FIN for all + // blocks of data written out. This is wrong if the POST data was larger than + // UploadDataStream::kBufSize as that is the largest buffer that + // UploadDataStream returns at a time and we'll be setting the FIN flag for + // each block of data written out. + bool eof = !is_chunked || request_body_stream_->IsOnLastChunk(); + return stream_->WriteStreamData( + request_body_stream_->buf(), buf_len, + eof ? spdy::DATA_FLAG_FIN : spdy::DATA_FLAG_NONE); } -bool SpdyHttpStream::OnSendBodyComplete(int status) { +int SpdyHttpStream::OnSendBodyComplete(int status, bool* eof) { CHECK(request_body_stream_.get()); + request_body_stream_->MarkConsumedAndFillBuffer(status); - return request_body_stream_->eof(); + *eof = request_body_stream_->eof(); + if (!*eof && + request_body_stream_->is_chunked() && + !request_body_stream_->buf_len()) + return ERR_IO_PENDING; + + return OK; } int SpdyHttpStream::OnResponseReceived(const spdy::SpdyHeaderBlock& response, |