Commit e3e96efd authored by rch's avatar rch Committed by Commit bot

Cancel a promised stream if it is for a request with a body in QuicHttpStream.

BUG=

Review-Url: https://codereview.chromium.org/2345663002
Cr-Commit-Position: refs/heads/master@{#418944}
parent e1de73b5
...@@ -116,9 +116,8 @@ void QuicHttpStream::OnRendezvousResult(QuicSpdyStream* stream) { ...@@ -116,9 +116,8 @@ void QuicHttpStream::OnRendezvousResult(QuicSpdyStream* stream) {
if (callback_.is_null()) if (callback_.is_null())
return; return;
if (stream) { DCHECK_EQ(STATE_HANDLE_PROMISE_COMPLETE, next_state_);
next_state_ = STATE_HANDLE_PROMISE_COMPLETE; if (!stream) {
} else {
// rendezvous has failed so proceed as with a non-push request. // rendezvous has failed so proceed as with a non-push request.
next_state_ = STATE_REQUEST_STREAM; next_state_ = STATE_REQUEST_STREAM;
} }
...@@ -173,16 +172,6 @@ int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info, ...@@ -173,16 +172,6 @@ int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info,
return rv; return rv;
} }
bool QuicHttpStream::CancelPromiseIfHasBody() {
if (!request_body_stream_)
return false;
// A request with a body is ineligble for push.
this->push_handle_->Cancel();
this->push_handle_ = nullptr;
return true;
}
int QuicHttpStream::DoHandlePromise() { int QuicHttpStream::DoHandlePromise() {
QuicAsyncStatus push_status = session_->push_promise_index()->Try( QuicAsyncStatus push_status = session_->push_promise_index()->Try(
request_headers_, this, &this->push_handle_); request_headers_, this, &this->push_handle_);
...@@ -196,14 +185,8 @@ int QuicHttpStream::DoHandlePromise() { ...@@ -196,14 +185,8 @@ int QuicHttpStream::DoHandlePromise() {
next_state_ = STATE_HANDLE_PROMISE_COMPLETE; next_state_ = STATE_HANDLE_PROMISE_COMPLETE;
break; break;
case QUIC_PENDING: case QUIC_PENDING:
if (!CancelPromiseIfHasBody()) { next_state_ = STATE_HANDLE_PROMISE_COMPLETE;
next_state_ = STATE_HANDLE_PROMISE_COMPLETE; return ERR_IO_PENDING;
// Have a promise but the promised stream doesn't exist yet.
// Still have to do validation before accepting the promised
// stream for sure.
return ERR_IO_PENDING;
}
next_state_ = STATE_REQUEST_STREAM;
} }
return OK; return OK;
} }
...@@ -212,11 +195,6 @@ int QuicHttpStream::DoHandlePromiseComplete(int rv) { ...@@ -212,11 +195,6 @@ int QuicHttpStream::DoHandlePromiseComplete(int rv) {
if (rv != OK) if (rv != OK)
return rv; return rv;
if (CancelPromiseIfHasBody()) {
next_state_ = STATE_REQUEST_STREAM;
return OK;
}
next_state_ = STATE_OPEN; next_state_ = STATE_OPEN;
stream_net_log_.AddEvent( stream_net_log_.AddEvent(
NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM, NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM,
...@@ -258,6 +236,18 @@ int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers, ...@@ -258,6 +236,18 @@ int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
// Store the request body. // Store the request body.
request_body_stream_ = request_info_->upload_data_stream; request_body_stream_ = request_info_->upload_data_stream;
if (request_body_stream_) { if (request_body_stream_) {
// A request with a body is ineligible for push, so reset the
// promised stream and request a new stream.
if (found_promise_) {
found_promise_ = false;
std::string url(request_info_->url.spec());
QuicClientPromisedInfo* promised =
session_->push_promise_index()->GetPromised(url);
if (promised != nullptr) {
session_->ResetPromised(promised->id(), QUIC_STREAM_CANCELLED);
}
}
// TODO(rch): Can we be more precise about when to allocate // TODO(rch): Can we be more precise about when to allocate
// raw_request_body_buf_. Removed the following check. DoReadRequestBody() // raw_request_body_buf_. Removed the following check. DoReadRequestBody()
// was being called even if we didn't yet allocate raw_request_body_buf_. // was being called even if we didn't yet allocate raw_request_body_buf_.
...@@ -277,9 +267,6 @@ int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers, ...@@ -277,9 +267,6 @@ int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
int rv; int rv;
if (found_promise_) { if (found_promise_) {
// TODO(rch): If this request has a body, instead of waiting for the pushed
// headers to arrive before canceling the push we could cancel the pushed
// stream now and go straight to STATE_REQUEST_STREAM.
next_state_ = STATE_HANDLE_PROMISE; next_state_ = STATE_HANDLE_PROMISE;
} else { } else {
next_state_ = STATE_SET_REQUEST_PRIORITY; next_state_ = STATE_SET_REQUEST_PRIORITY;
......
...@@ -134,7 +134,6 @@ class NET_EXPORT_PRIVATE QuicHttpStream ...@@ -134,7 +134,6 @@ class NET_EXPORT_PRIVATE QuicHttpStream
void EnterStateSendHeaders(); void EnterStateSendHeaders();
void ResetStream(); void ResetStream();
bool CancelPromiseIfHasBody();
State next_state_; State next_state_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment