Index: net/spdy/spdy_http_stream.cc |
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc |
index 259581a5229173cc2e7fcbc84963396f357c0d80..8891b0abe5d401579fb7137e1b2214400c09bd7b 100644 |
--- a/net/spdy/spdy_http_stream.cc |
+++ b/net/spdy/spdy_http_stream.cc |
@@ -302,13 +302,15 @@ void SpdyHttpStream::Cancel() { |
} |
void SpdyHttpStream::OnRequestHeadersSent() { |
- if (!request_callback_.is_null()) |
- DoRequestCallback(OK); |
- |
// TODO(akalin): Do this immediately after sending the request |
// headers. |
- if (HasUploadData()) |
+ if (HasUploadData()) { |
ReadAndSendRequestBodyData(); |
+ return; |
+ } |
+ |
+ if (!request_callback_.is_null()) |
+ DoRequestCallback(OK); |
} |
SpdyResponseHeadersStatus SpdyHttpStream::OnResponseHeadersUpdated( |
@@ -448,25 +450,41 @@ void SpdyHttpStream::ReadAndSendRequestBodyData() { |
weak_factory_.GetWeakPtr())); |
if (rv != ERR_IO_PENDING) { |
- // ERR_IO_PENDING is the only possible error. |
- CHECK_GE(rv, 0); |
+ // UploadDataStream::Read() can fail reading data |
OnRequestBodyReadCompleted(rv); |
} |
} |
+void SpdyHttpStream::ResetStreamInternal() { |
+ spdy_session_->ResetStream(stream()->stream_id(), RST_STREAM_INTERNAL_ERROR, |
+ std::string()); |
+} |
+ |
void SpdyHttpStream::OnRequestBodyReadCompleted(int status) { |
- CHECK_GE(status, 0); |
- request_body_buf_size_ = status; |
- const bool eof = request_info_->upload_data_stream->IsEOF(); |
- // Only the final fame may have a length of 0. |
- if (eof) { |
- CHECK_GE(request_body_buf_size_, 0); |
+ if (status < 0) { |
+ DCHECK_NE(ERR_IO_PENDING, status); |
+ |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, base::Bind(&SpdyHttpStream::ResetStreamInternal, |
+ weak_factory_.GetWeakPtr())); |
} else { |
- CHECK_GT(request_body_buf_size_, 0); |
+ CHECK_GE(status, 0); |
+ request_body_buf_size_ = status; |
+ const bool eof = request_info_->upload_data_stream->IsEOF(); |
+ // Only the final fame may have a length of 0. |
+ if (eof) { |
+ CHECK_GE(request_body_buf_size_, 0); |
+ } else { |
+ CHECK_GT(request_body_buf_size_, 0); |
+ } |
+ stream_->SendData(request_body_buf_.get(), request_body_buf_size_, |
+ eof ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND); |
+ } |
+ |
+ if (!request_callback_.is_null()) { |
+ int result = status > 0 ? OK : status; |
+ DoRequestCallback(result); |
} |
- stream_->SendData(request_body_buf_.get(), |
- request_body_buf_size_, |
- eof ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND); |
} |
void SpdyHttpStream::ScheduleBufferedReadCallback() { |