Chromium Code Reviews| Index: net/spdy/spdy_http_stream.cc |
| diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc |
| index 6a6abb241f84a1bd83a07c0d3ae822a3a1ffdae4..8fc075299d3c521bc9d9cc7fd2a679bf6ce29473 100644 |
| --- a/net/spdy/spdy_http_stream.cc |
| +++ b/net/spdy/spdy_http_stream.cc |
| @@ -33,7 +33,8 @@ SpdyHttpStream::SpdyHttpStream(SpdySession* spdy_session, |
| user_buffer_len_(0), |
| buffered_read_callback_pending_(false), |
| more_read_data_pending_(false), |
| - direct_(direct) { } |
| + direct_(direct), |
| + send_last_chunk_(false) { } |
| void SpdyHttpStream::InitializeWithExistingStream(SpdyStream* spdy_stream) { |
| stream_ = spdy_stream; |
| @@ -175,6 +176,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, |
| @@ -198,7 +204,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; |
| @@ -255,17 +261,40 @@ bool SpdyHttpStream::OnSendHeadersComplete(int status) { |
| int SpdyHttpStream::OnSendBody() { |
| CHECK(request_body_stream_.get()); |
| + if (send_last_chunk_) { |
| + return stream_->WriteStreamData(request_body_stream_->buf(), 0, |
| + spdy::DATA_FLAG_FIN); |
| + } |
| + |
| int buf_len = static_cast<int>(request_body_stream_->buf_len()); |
| if (!buf_len) |
| return OK; |
| + bool is_chunked = request_body_stream_->is_chunked(); |
| return stream_->WriteStreamData(request_body_stream_->buf(), buf_len, |
|
willchan no longer on Chromium
2011/02/01 23:35:59
http://google-styleguide.googlecode.com/svn/trunk/
Satish
2011/02/22 14:25:44
Done.
|
| - spdy::DATA_FLAG_FIN); |
| + is_chunked ? spdy::DATA_FLAG_NONE : spdy::DATA_FLAG_FIN); |
| } |
| -bool SpdyHttpStream::OnSendBodyComplete(int status) { |
| +bool SpdyHttpStream::OnSendBodyComplete(int* status) { |
| CHECK(request_body_stream_.get()); |
| - request_body_stream_->MarkConsumedAndFillBuffer(status); |
| - return request_body_stream_->eof(); |
| + |
| + *status = OK; |
| + if (send_last_chunk_) // Indicates that the last chunk was SENT here. |
| + return true; |
| + |
| + request_body_stream_->MarkConsumedAndFillBuffer(*status); |
|
willchan no longer on Chromium
2011/02/01 23:35:59
I'm confused how this works. OK == 0. You set *sta
Satish
2011/02/22 14:25:44
This was a last minute copy/paste error, fixed now
|
| + |
| + bool eof = request_body_stream_->eof(); |
| + if (request_body_stream_->is_chunked()) { |
| + if (eof) { |
| + send_last_chunk_ = true; |
| + eof = false; |
| + } else { |
| + if (!request_body_stream_->buf_len()) |
| + *status = ERR_IO_PENDING; |
| + } |
| + } |
| + |
| + return eof; |
| } |
| int SpdyHttpStream::OnResponseReceived(const spdy::SpdyHeaderBlock& response, |