diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 17:24:50 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 17:24:50 +0000 |
commit | 82918ccd87a794552905fc3a9b04c8afae1bc4ca (patch) | |
tree | e8bbe1df61dc06df43e2c2b94973c0bfb90147da /net/spdy | |
parent | 08f44aa3b9de47dec72f931ff36db9c1d067aeed (diff) | |
download | chromium_src-82918ccd87a794552905fc3a9b04c8afae1bc4ca.zip chromium_src-82918ccd87a794552905fc3a9b04c8afae1bc4ca.tar.gz chromium_src-82918ccd87a794552905fc3a9b04c8afae1bc4ca.tar.bz2 |
Move the stream initialization out of the HttpStreamRequest and back
into the HttpNetworkTransaction. The reason is because the stream
factory should get the stream connected, but not actually initialize
the stream; stream initialization should only happen when the stream
uses it.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3137034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57342 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r-- | net/spdy/spdy_http_stream.cc | 11 | ||||
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 55 |
2 files changed, 55 insertions, 11 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index 622d2c0..de0cc14 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -170,6 +170,9 @@ SpdyHttpStream::~SpdyHttpStream() { int SpdyHttpStream::InitializeStream(const HttpRequestInfo* request_info, const BoundNetLog& stream_net_log, CompletionCallback* callback) { + if (spdy_session_->IsClosed()) + return ERR_CONNECTION_CLOSED; + request_info_ = request_info; if (request_info_->method == "GET") { int error = spdy_session_->GetPushStream(request_info_->url, &stream_, @@ -180,10 +183,10 @@ int SpdyHttpStream::InitializeStream(const HttpRequestInfo* request_info, if (stream_.get()) return OK; - else - return spdy_session_->CreateStream(request_info_->url, - request_info_->priority, &stream_, - stream_net_log, callback); + + return spdy_session_->CreateStream(request_info_->url, + request_info_->priority, &stream_, + stream_net_log, callback); } const HttpResponseInfo* SpdyHttpStream::GetResponseInfo() const { diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index f194eff..b3738a6 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -1307,13 +1307,11 @@ TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) { scoped_ptr<UploadDataStream> stream(UploadDataStream::Create( request.upload_data, NULL)); ASSERT_EQ(request.upload_data->GetContentLength(), stream->size()); - - scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); - - scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); + scoped_ptr<spdy::SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); + scoped_ptr<spdy::SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); MockRead reads[] = { - CreateMockRead(*resp.get(), 2), - CreateMockRead(*body.get(), 3), + CreateMockRead(*stream_reply, 2), + CreateMockRead(*stream_body, 3), MockRead(false, 0, 0) // EOF }; @@ -1327,7 +1325,7 @@ TEST_P(SpdyNetworkTransactionTest, PostWithEarlySynReply) { helper.VerifyDataConsumed(); TransactionHelperResult out = helper.output(); - EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); + EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); } // The client upon cancellation tries to send a RST_STREAM frame. The mock @@ -2228,6 +2226,49 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame) { EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); } +TEST_P(SpdyNetworkTransactionTest, ServerPushSingleDataFrame2) { + static const unsigned char kPushBodyFrame[] = { + 0x00, 0x00, 0x00, 0x02, // header, ID + 0x01, 0x00, 0x00, 0x06, // FIN, length + 'p', 'u', 's', 'h', 'e', 'd' // "pushed" + }; + scoped_ptr<spdy::SpdyFrame> + stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); + MockWrite writes[] = { + CreateMockWrite(*stream1_syn, 1), + }; + + scoped_ptr<spdy::SpdyFrame> + stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); + scoped_ptr<spdy::SpdyFrame> + stream2_syn(ConstructSpdyPush(NULL, 0, 2, 1, "/foo.dat")); + scoped_ptr<spdy::SpdyFrame> + stream1_body(ConstructSpdyBodyFrame(1, true)); + MockRead reads[] = { + CreateMockRead(*stream1_reply, 2), + CreateMockRead(*stream2_syn, 3), + MockRead(true, reinterpret_cast<const char*>(kPushBodyFrame), + arraysize(kPushBodyFrame), 5), + CreateMockRead(*stream1_body, 4, false), + MockRead(true, ERR_IO_PENDING, 6), // Force a pause + }; + + HttpResponseInfo response; + HttpResponseInfo response2; + std::string expected_push_result("pushed"); + RunServerPushTest(writes, arraysize(writes), reads, arraysize(reads), + &response, &response2, expected_push_result); + + // Verify the SYN_REPLY. + EXPECT_TRUE(response.headers != NULL); + EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); + + // Verify the pushed stream. + EXPECT_TRUE(response2.headers != NULL); + EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); +} + + TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) { scoped_ptr<spdy::SpdyFrame> stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |