Chromium Code Reviews| Index: net/http/http_network_transaction_unittest.cc |
| diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc |
| index 0bb806c1526a4f7a670a71eee705ee2a35beba3c..15ba0fc17bde20d088e96064b4def58077b1c6f4 100644 |
| --- a/net/http/http_network_transaction_unittest.cc |
| +++ b/net/http/http_network_transaction_unittest.cc |
| @@ -708,6 +708,58 @@ TEST_F(HttpNetworkTransactionTest, SimpleGETNoHeaders) { |
| EXPECT_EQ(reads_size, out.total_received_bytes); |
| } |
| +// Response with no status line, and a weird port. Should fail by default. |
| +TEST_F(HttpNetworkTransactionTest, SimpleGETNoHeadersWeirdPort) { |
| + MockRead data_reads[] = { |
| + MockRead("hello world"), MockRead(SYNCHRONOUS, OK), |
| + }; |
| + |
| + StaticSocketDataProvider data(data_reads, arraysize(data_reads), nullptr, 0); |
| + session_deps_.socket_factory->AddSocketDataProvider(&data); |
| + |
| + std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| + |
| + std::unique_ptr<HttpTransaction> trans( |
| + new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| + |
| + HttpRequestInfo request; |
| + request.method = "GET"; |
| + request.url = GURL("http://www.example.com:2000/"); |
| + TestCompletionCallback callback; |
| + int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| + EXPECT_THAT(callback.GetResult(rv), IsError(ERR_INVALID_HTTP_RESPONSE)); |
| +} |
| + |
| +// Response with no status line, and a weird port. Option to allow weird ports |
| +// enabled. |
| +TEST_F(HttpNetworkTransactionTest, SimpleGETNoHeadersWeirdPortAllowed) { |
| + MockRead data_reads[] = { |
| + MockRead("hello world"), MockRead(SYNCHRONOUS, OK), |
| + }; |
| + |
| + StaticSocketDataProvider data(data_reads, arraysize(data_reads), nullptr, 0); |
| + session_deps_.socket_factory->AddSocketDataProvider(&data); |
| + session_deps_.http_09_on_non_default_ports_enabled = true; |
| + std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| + |
| + std::unique_ptr<HttpTransaction> trans( |
| + new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| + |
| + HttpRequestInfo request; |
| + request.method = "GET"; |
| + request.url = GURL("http://www.example.com:2000/"); |
| + TestCompletionCallback callback; |
| + int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| + EXPECT_THAT(callback.GetResult(rv), IsOk()); |
| + |
| + const HttpResponseInfo* info = trans->GetResponseInfo(); |
| + ASSERT_TRUE(info->headers); |
| + EXPECT_EQ("HTTP/0.9 200 OK", info->headers->GetStatusLine()); |
| + |
| + // Don't bother to read the body - that's verified elsewhere, importand thing |
|
eroman
2016/08/29 22:11:55
importand
mmenke
2016/08/30 17:50:47
Done.
|
| + // is that the option to allow HTTP/0.9 on non-default ports is respected. |
| +} |
| + |
| // Allow up to 4 bytes of junk to precede status line. |
| TEST_F(HttpNetworkTransactionTest, StatusLineJunk3Bytes) { |
| MockRead data_reads[] = { |
| @@ -14296,7 +14348,7 @@ class FakeWebSocketBasicHandshakeStream : public WebSocketHandshakeStreamBase { |
| FakeWebSocketBasicHandshakeStream( |
| std::unique_ptr<ClientSocketHandle> connection, |
| bool using_proxy) |
| - : state_(std::move(connection), using_proxy) {} |
| + : state_(std::move(connection), using_proxy, false) {} |
| // Fake implementation of HttpStreamBase methods. |
| // This ends up being quite "real" because this object has to really send data |