Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 138803002: SPDY4: Turn SYN_STREAM and SYN_REPLY into HEADERS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows bool-cast fix. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 request.method = "POST"; 1964 request.method = "POST";
1965 request.url = GURL(kRequestUrl); 1965 request.url = GURL(kRequestUrl);
1966 // Create an empty UploadData. 1966 // Create an empty UploadData.
1967 request.upload_data_stream = NULL; 1967 request.upload_data_stream = NULL;
1968 1968
1969 // When request.upload_data_stream is NULL for post, content-length is 1969 // When request.upload_data_stream is NULL for post, content-length is
1970 // expected to be 0. 1970 // expected to be 0.
1971 scoped_ptr<SpdyFrame> req( 1971 scoped_ptr<SpdyFrame> req(
1972 spdy_util_.ConstructSpdyPost(kRequestUrl, 1, 0, LOWEST, NULL, 0)); 1972 spdy_util_.ConstructSpdyPost(kRequestUrl, 1, 0, LOWEST, NULL, 0));
1973 // Set the FIN bit since there will be no body. 1973 // Set the FIN bit since there will be no body.
1974 test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, spdy_util_.spdy_version()); 1974 int flags = CONTROL_FLAG_FIN;
1975 if (spdy_util_.spdy_version() >= SPDY4) {
1976 flags |= HEADERS_FLAG_PRIORITY;
1977 }
1978 test::SetFrameFlags(req.get(), flags, spdy_util_.spdy_version());
1975 MockWrite writes[] = { 1979 MockWrite writes[] = {
1976 CreateMockWrite(*req), 1980 CreateMockWrite(*req),
1977 }; 1981 };
1978 1982
1979 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); 1983 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
1980 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 1984 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
1981 MockRead reads[] = { 1985 MockRead reads[] = {
1982 CreateMockRead(*resp), 1986 CreateMockRead(*resp),
1983 CreateMockRead(*body), 1987 CreateMockRead(*body),
1984 MockRead(ASYNC, 0, 0) // EOF 1988 MockRead(ASYNC, 0, 0) // EOF
(...skipping 21 matching lines...) Expand all
2006 HttpRequestInfo request; 2010 HttpRequestInfo request;
2007 request.method = "POST"; 2011 request.method = "POST";
2008 request.url = GURL(kRequestUrl); 2012 request.url = GURL(kRequestUrl);
2009 request.upload_data_stream = &stream; 2013 request.upload_data_stream = &stream;
2010 2014
2011 const uint64 kContentLength = 0; 2015 const uint64 kContentLength = 0;
2012 scoped_ptr<SpdyFrame> req( 2016 scoped_ptr<SpdyFrame> req(
2013 spdy_util_.ConstructSpdyPost( 2017 spdy_util_.ConstructSpdyPost(
2014 kRequestUrl, 1, kContentLength, LOWEST, NULL, 0)); 2018 kRequestUrl, 1, kContentLength, LOWEST, NULL, 0));
2015 // Set the FIN bit since there will be no body. 2019 // Set the FIN bit since there will be no body.
2016 test::SetFrameFlags(req.get(), CONTROL_FLAG_FIN, spdy_util_.spdy_version()); 2020 int flags = CONTROL_FLAG_FIN;
2021 if (spdy_util_.spdy_version() >= SPDY4) {
2022 flags |= HEADERS_FLAG_PRIORITY;
2023 }
2024 test::SetFrameFlags(req.get(), flags, spdy_util_.spdy_version());
2017 MockWrite writes[] = { 2025 MockWrite writes[] = {
2018 CreateMockWrite(*req), 2026 CreateMockWrite(*req),
2019 }; 2027 };
2020 2028
2021 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); 2029 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
2022 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 2030 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
2023 MockRead reads[] = { 2031 MockRead reads[] = {
2024 CreateMockRead(*resp), 2032 CreateMockRead(*resp),
2025 CreateMockRead(*body), 2033 CreateMockRead(*body),
2026 MockRead(ASYNC, 0, 0) // EOF 2034 MockRead(ASYNC, 0, 0) // EOF
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 TransactionHelperResult out = helper.output(); 2156 TransactionHelperResult out = helper.output();
2149 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 2157 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
2150 } 2158 }
2151 2159
2152 // Test that the transaction doesn't crash when we get two replies on the same 2160 // Test that the transaction doesn't crash when we get two replies on the same
2153 // stream ID. See http://crbug.com/45639. 2161 // stream ID. See http://crbug.com/45639.
2154 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { 2162 TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) {
2155 scoped_ptr<SpdyFrame> req( 2163 scoped_ptr<SpdyFrame> req(
2156 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 2164 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
2157 scoped_ptr<SpdyFrame> rst( 2165 scoped_ptr<SpdyFrame> rst(
2158 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_STREAM_IN_USE)); 2166 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
2159 MockWrite writes[] = { 2167 MockWrite writes[] = {
2160 CreateMockWrite(*req), 2168 CreateMockWrite(*req),
2161 CreateMockWrite(*rst), 2169 CreateMockWrite(*rst),
2162 }; 2170 };
2163 2171
2164 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 2172 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
2165 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 2173 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true));
2166 MockRead reads[] = { 2174 MockRead reads[] = {
2167 CreateMockRead(*resp), 2175 CreateMockRead(*resp),
2168 CreateMockRead(*resp), 2176 CreateMockRead(*resp),
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 // Verify the SYN_REPLY. 3036 // Verify the SYN_REPLY.
3029 EXPECT_TRUE(response.headers.get() != NULL); 3037 EXPECT_TRUE(response.headers.get() != NULL);
3030 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3038 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3031 3039
3032 // Verify the pushed stream. 3040 // Verify the pushed stream.
3033 EXPECT_TRUE(response2.headers.get() != NULL); 3041 EXPECT_TRUE(response2.headers.get() != NULL);
3034 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 3042 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
3035 } 3043 }
3036 3044
3037 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { 3045 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) {
3046 if (spdy_util_.spdy_version() == SPDY4) {
3047 // TODO(jgraettinger): We don't support associated stream
3048 // checks in SPDY4 yet.
3049 return;
3050 }
3038 scoped_ptr<SpdyFrame> stream1_syn( 3051 scoped_ptr<SpdyFrame> stream1_syn(
3039 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 3052 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
3040 scoped_ptr<SpdyFrame> stream1_body( 3053 scoped_ptr<SpdyFrame> stream1_body(
3041 spdy_util_.ConstructSpdyBodyFrame(1, true)); 3054 spdy_util_.ConstructSpdyBodyFrame(1, true));
3042 scoped_ptr<SpdyFrame> stream2_rst( 3055 scoped_ptr<SpdyFrame> stream2_rst(
3043 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); 3056 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM));
3044 MockWrite writes[] = { 3057 MockWrite writes[] = {
3045 CreateMockWrite(*stream1_syn, 1), 3058 CreateMockWrite(*stream1_syn, 1),
3046 CreateMockWrite(*stream2_rst, 4), 3059 CreateMockWrite(*stream2_rst, 4),
3047 }; 3060 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 << " Write index: " 3102 << " Write index: "
3090 << data.write_index(); 3103 << data.write_index();
3091 3104
3092 // Verify the SYN_REPLY. 3105 // Verify the SYN_REPLY.
3093 HttpResponseInfo response = *trans->GetResponseInfo(); 3106 HttpResponseInfo response = *trans->GetResponseInfo();
3094 EXPECT_TRUE(response.headers.get() != NULL); 3107 EXPECT_TRUE(response.headers.get() != NULL);
3095 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 3108 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
3096 } 3109 }
3097 3110
3098 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) { 3111 TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) {
3112 if (spdy_util_.spdy_version() == SPDY4) {
3113 // TODO(jgraettinger): We don't support associated stream
3114 // checks in SPDY4 yet.
3115 return;
3116 }
3099 scoped_ptr<SpdyFrame> stream1_syn( 3117 scoped_ptr<SpdyFrame> stream1_syn(
3100 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 3118 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
3101 scoped_ptr<SpdyFrame> stream1_body( 3119 scoped_ptr<SpdyFrame> stream1_body(
3102 spdy_util_.ConstructSpdyBodyFrame(1, true)); 3120 spdy_util_.ConstructSpdyBodyFrame(1, true));
3103 scoped_ptr<SpdyFrame> stream2_rst( 3121 scoped_ptr<SpdyFrame> stream2_rst(
3104 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM)); 3122 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_INVALID_STREAM));
3105 MockWrite writes[] = { 3123 MockWrite writes[] = {
3106 CreateMockWrite(*stream1_syn, 1), 3124 CreateMockWrite(*stream1_syn, 1),
3107 CreateMockWrite(*stream2_rst, 4), 3125 CreateMockWrite(*stream2_rst, 4),
3108 }; 3126 };
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
5574 DelayedSocketData data(1, reads, arraysize(reads), 5592 DelayedSocketData data(1, reads, arraysize(reads),
5575 writes, arraysize(writes)); 5593 writes, arraysize(writes));
5576 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, 5594 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
5577 BoundNetLog(), GetParam(), NULL); 5595 BoundNetLog(), GetParam(), NULL);
5578 helper.RunToCompletion(&data); 5596 helper.RunToCompletion(&data);
5579 TransactionHelperResult out = helper.output(); 5597 TransactionHelperResult out = helper.output();
5580 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); 5598 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv);
5581 } 5599 }
5582 5600
5583 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { 5601 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) {
5602 if (spdy_util_.spdy_version() == SPDY4) {
5603 // TODO(jgraettinger): We don't support associated stream
5604 // checks in SPDY4 yet.
5605 return;
5606 }
5584 // In this test we want to verify that we can't accidentally push content 5607 // In this test we want to verify that we can't accidentally push content
5585 // which can't be pushed by this content server. 5608 // which can't be pushed by this content server.
5586 // This test assumes that: 5609 // This test assumes that:
5587 // - if we're requesting http://www.foo.com/barbaz 5610 // - if we're requesting http://www.foo.com/barbaz
5588 // - the browser has made a connection to "www.foo.com". 5611 // - the browser has made a connection to "www.foo.com".
5589 5612
5590 // A list of the URL to fetch, followed by the URL being pushed. 5613 // A list of the URL to fetch, followed by the URL being pushed.
5591 static const char* const kTestCases[] = { 5614 static const char* const kTestCases[] = {
5592 "http://www.google.com/foo.html", 5615 "http://www.google.com/foo.html",
5593 "http://www.google.com:81/foo.js", // Bad port 5616 "http://www.google.com:81/foo.js", // Bad port
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
6467 // since we're send-stalled. 6490 // since we're send-stalled.
6468 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); 6491 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control());
6469 6492
6470 // Read in WINDOW_UPDATE or SETTINGS frame. 6493 // Read in WINDOW_UPDATE or SETTINGS frame.
6471 data.RunFor((GetParam().protocol >= kProtoSPDY31) ? 8 : 7); 6494 data.RunFor((GetParam().protocol >= kProtoSPDY31) ? 8 : 7);
6472 rv = callback.WaitForResult(); 6495 rv = callback.WaitForResult();
6473 helper.VerifyDataConsumed(); 6496 helper.VerifyDataConsumed();
6474 } 6497 }
6475 6498
6476 } // namespace net 6499 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698