OLD | NEW |
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 <cmath> | 5 #include <cmath> |
6 #include <memory> | 6 #include <memory> |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 6173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6184 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 6184 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
6185 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 6185 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
6186 NetLogWithSource(), nullptr); | 6186 NetLogWithSource(), nullptr); |
6187 helper.RunToCompletion(&data); | 6187 helper.RunToCompletion(&data); |
6188 TransactionHelperResult out = helper.output(); | 6188 TransactionHelperResult out = helper.output(); |
6189 EXPECT_THAT(out.rv, IsOk()); | 6189 EXPECT_THAT(out.rv, IsOk()); |
6190 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 6190 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
6191 EXPECT_EQ("hello!", out.response_data); | 6191 EXPECT_EQ("hello!", out.response_data); |
6192 } | 6192 } |
6193 | 6193 |
| 6194 // "A server can send a complete response prior to the client sending an entire |
| 6195 // request if the response does not depend on any portion of the request that |
| 6196 // has not been sent and received." (RFC7540 Section 8.1) |
| 6197 // Regression test for https://crbug.com/606990. Server responds before POST |
| 6198 // data are sent and closes connection: this must result in |
| 6199 // ERR_CONNECTION_CLOSED (as opposed to ERR_SPDY_PROTOCOL_ERROR). |
| 6200 TEST_F(SpdyNetworkTransactionTest, ResponseBeforePostDataSent) { |
| 6201 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 6202 MockWrite writes[] = {CreateMockWrite(req, 0)}; |
| 6203 |
| 6204 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 6205 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 6206 MockRead reads[] = {CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 6207 MockRead(ASYNC, 0, 3)}; |
| 6208 |
| 6209 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 6210 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), |
| 6211 DEFAULT_PRIORITY, NetLogWithSource(), |
| 6212 nullptr); |
| 6213 |
| 6214 helper.RunPreTestSetup(); |
| 6215 helper.AddData(&data); |
| 6216 helper.StartDefaultTest(); |
| 6217 EXPECT_THAT(helper.output().rv, IsError(ERR_IO_PENDING)); |
| 6218 helper.WaitForCallbackToComplete(); |
| 6219 EXPECT_THAT(helper.output().rv, IsError(ERR_CONNECTION_CLOSED)); |
| 6220 } |
| 6221 |
| 6222 // Regression test for https://crbug.com/606990. |
| 6223 // Server responds before POST data are sent and resets stream with NO_ERROR. |
| 6224 TEST_F(SpdyNetworkTransactionTest, ResponseAndRstStreamBeforePostDataSent) { |
| 6225 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 6226 MockWrite writes[] = {CreateMockWrite(req, 0)}; |
| 6227 |
| 6228 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 6229 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 6230 SpdySerializedFrame rst( |
| 6231 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_NO_ERROR)); |
| 6232 MockRead reads[] = {CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 6233 CreateMockRead(rst, 3), MockRead(ASYNC, 0, 4)}; |
| 6234 |
| 6235 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
| 6236 NormalSpdyTransactionHelper helper(CreateChunkedPostRequest(), |
| 6237 DEFAULT_PRIORITY, NetLogWithSource(), |
| 6238 nullptr); |
| 6239 |
| 6240 helper.RunToCompletion(&data); |
| 6241 |
| 6242 TransactionHelperResult out = helper.output(); |
| 6243 EXPECT_THAT(out.rv, IsOk()); |
| 6244 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 6245 EXPECT_EQ("hello!", out.response_data); |
| 6246 } |
| 6247 |
6194 class SpdyNetworkTransactionTLSUsageCheckTest | 6248 class SpdyNetworkTransactionTLSUsageCheckTest |
6195 : public SpdyNetworkTransactionTest { | 6249 : public SpdyNetworkTransactionTest { |
6196 protected: | 6250 protected: |
6197 void RunTLSUsageCheckTest( | 6251 void RunTLSUsageCheckTest( |
6198 std::unique_ptr<SSLSocketDataProvider> ssl_provider) { | 6252 std::unique_ptr<SSLSocketDataProvider> ssl_provider) { |
6199 SpdySerializedFrame goaway( | 6253 SpdySerializedFrame goaway( |
6200 spdy_util_.ConstructSpdyGoAway(0, GOAWAY_INADEQUATE_SECURITY, "")); | 6254 spdy_util_.ConstructSpdyGoAway(0, GOAWAY_INADEQUATE_SECURITY, "")); |
6201 MockWrite writes[] = {CreateMockWrite(goaway)}; | 6255 MockWrite writes[] = {CreateMockWrite(goaway)}; |
6202 | 6256 |
6203 StaticSocketDataProvider data(NULL, 0, writes, arraysize(writes)); | 6257 StaticSocketDataProvider data(NULL, 0, writes, arraysize(writes)); |
(...skipping 20 matching lines...) Expand all Loading... |
6224 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6278 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6225 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 6279 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
6226 new SSLSocketDataProvider(ASYNC, OK)); | 6280 new SSLSocketDataProvider(ASYNC, OK)); |
6227 // Set to TLS_RSA_WITH_NULL_MD5 | 6281 // Set to TLS_RSA_WITH_NULL_MD5 |
6228 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6282 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6229 | 6283 |
6230 RunTLSUsageCheckTest(std::move(ssl_provider)); | 6284 RunTLSUsageCheckTest(std::move(ssl_provider)); |
6231 } | 6285 } |
6232 | 6286 |
6233 } // namespace net | 6287 } // namespace net |
OLD | NEW |