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

Fix bug in QuicHttpStream::SendRequest.

If the session is closed before SendRequest is called, a CHECK would fire in SendRequest().

BUG=409101

Review URL: https://codereview.chromium.org/523463007

Cr-Commit-Position: refs/heads/master@{#292775}
parent aa53c902
......@@ -103,12 +103,15 @@ void QuicHttpStream::OnStreamReady(int rv) {
int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
HttpResponseInfo* response,
const CompletionCallback& callback) {
CHECK(stream_);
CHECK(!request_body_stream_);
CHECK(!response_info_);
CHECK(!callback.is_null());
CHECK(response);
if (!stream_) {
return ERR_CONNECTION_CLOSED;
}
QuicPriority priority = ConvertRequestPriorityToQuicPriority(priority_);
stream_->set_priority(priority);
// Store the serialized request headers.
......@@ -353,6 +356,7 @@ void QuicHttpStream::OnCryptoHandshakeConfirmed() {
}
void QuicHttpStream::OnSessionClosed(int error) {
Close(false);
session_error_ = error;
session_.reset();
}
......
......@@ -440,6 +440,24 @@ TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) {
EXPECT_TRUE(AtEof());
}
// Regression test for http://crbug.com/409101
TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) {
SetRequest("GET", "/", DEFAULT_PRIORITY);
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY,
net_log_, callback_.callback()));
session_->connection()->CloseConnection(QUIC_NO_ERROR, true);
EXPECT_EQ(ERR_CONNECTION_CLOSED,
stream_->SendRequest(headers_, &response_,
callback_.callback()));
}
TEST_P(QuicHttpStreamTest, SendPostRequest) {
SetRequest("POST", "/", DEFAULT_PRIORITY);
AddWrite(ConstructRequestHeadersPacket(1, !kFin));
......
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