OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <limits> | 10 #include <limits> |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 return out; | 390 return out; |
391 } | 391 } |
392 out.status_line = response->headers->GetStatusLine(); | 392 out.status_line = response->headers->GetStatusLine(); |
393 | 393 |
394 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 394 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
395 EXPECT_EQ(80, response->socket_address.port()); | 395 EXPECT_EQ(80, response->socket_address.port()); |
396 | 396 |
397 bool got_endpoint = | 397 bool got_endpoint = |
398 trans->GetRemoteEndpoint(&out.remote_endpoint_after_start); | 398 trans->GetRemoteEndpoint(&out.remote_endpoint_after_start); |
399 EXPECT_EQ(got_endpoint, | 399 EXPECT_EQ(got_endpoint, |
400 out.remote_endpoint_after_start.address().size() > 0); | 400 out.remote_endpoint_after_start.address().bytes().size() > 0); |
401 | 401 |
402 rv = ReadTransaction(trans.get(), &out.response_data); | 402 rv = ReadTransaction(trans.get(), &out.response_data); |
403 EXPECT_EQ(OK, rv); | 403 EXPECT_EQ(OK, rv); |
404 | 404 |
405 TestNetLogEntry::List entries; | 405 TestNetLogEntry::List entries; |
406 log.GetEntries(&entries); | 406 log.GetEntries(&entries); |
407 size_t pos = ExpectLogContainsSomewhere( | 407 size_t pos = ExpectLogContainsSomewhere( |
408 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, | 408 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, |
409 NetLog::PHASE_NONE); | 409 NetLog::PHASE_NONE); |
410 ExpectLogContainsSomewhere( | 410 ExpectLogContainsSomewhere( |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1638 TestCompletionCallback callback; | 1638 TestCompletionCallback callback; |
1639 | 1639 |
1640 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1640 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1641 EXPECT_EQ(ERR_IO_PENDING, rv); | 1641 EXPECT_EQ(ERR_IO_PENDING, rv); |
1642 | 1642 |
1643 rv = callback.WaitForResult(); | 1643 rv = callback.WaitForResult(); |
1644 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 1644 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
1645 | 1645 |
1646 IPEndPoint endpoint; | 1646 IPEndPoint endpoint; |
1647 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); | 1647 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); |
1648 EXPECT_LT(0u, endpoint.address().size()); | 1648 EXPECT_LT(0u, endpoint.address().bytes().size()); |
1649 } | 1649 } |
1650 | 1650 |
1651 // What do various browsers do when the server closes a non-keepalive | 1651 // What do various browsers do when the server closes a non-keepalive |
1652 // connection without sending any response header or body? | 1652 // connection without sending any response header or body? |
1653 // | 1653 // |
1654 // IE7: error page | 1654 // IE7: error page |
1655 // Safari 3.1.2 (Windows): error page | 1655 // Safari 3.1.2 (Windows): error page |
1656 // Firefox 3.0.1: blank page | 1656 // Firefox 3.0.1: blank page |
1657 // Opera 9.52: after five attempts, blank page | 1657 // Opera 9.52: after five attempts, blank page |
1658 // Us with WinHTTP: error page (ERR_INVALID_RESPONSE) | 1658 // Us with WinHTTP: error page (ERR_INVALID_RESPONSE) |
(...skipping 7395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9054 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9054 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9055 | 9055 |
9056 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9056 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9057 EXPECT_EQ(ERR_IO_PENDING, rv); | 9057 EXPECT_EQ(ERR_IO_PENDING, rv); |
9058 | 9058 |
9059 rv = callback.WaitForResult(); | 9059 rv = callback.WaitForResult(); |
9060 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 9060 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
9061 | 9061 |
9062 IPEndPoint endpoint; | 9062 IPEndPoint endpoint; |
9063 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); | 9063 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); |
9064 EXPECT_LT(0u, endpoint.address().size()); | 9064 EXPECT_LT(0u, endpoint.address().bytes().size()); |
eroman
2016/01/13 23:19:42
same here
martijnc
2016/01/14 22:48:17
Done.
| |
9065 } | 9065 } |
9066 | 9066 |
9067 // Check that a connection closed after the start of the headers finishes ok. | 9067 // Check that a connection closed after the start of the headers finishes ok. |
9068 TEST_P(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { | 9068 TEST_P(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { |
9069 HttpRequestInfo request; | 9069 HttpRequestInfo request; |
9070 request.method = "GET"; | 9070 request.method = "GET"; |
9071 request.url = GURL("http://www.foo.com/"); | 9071 request.url = GURL("http://www.foo.com/"); |
9072 request.load_flags = 0; | 9072 request.load_flags = 0; |
9073 | 9073 |
9074 MockRead data_reads[] = { | 9074 MockRead data_reads[] = { |
(...skipping 22 matching lines...) Expand all Loading... | |
9097 EXPECT_TRUE(response->headers.get() != NULL); | 9097 EXPECT_TRUE(response->headers.get() != NULL); |
9098 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 9098 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
9099 | 9099 |
9100 std::string response_data; | 9100 std::string response_data; |
9101 rv = ReadTransaction(trans.get(), &response_data); | 9101 rv = ReadTransaction(trans.get(), &response_data); |
9102 EXPECT_EQ(OK, rv); | 9102 EXPECT_EQ(OK, rv); |
9103 EXPECT_EQ("", response_data); | 9103 EXPECT_EQ("", response_data); |
9104 | 9104 |
9105 IPEndPoint endpoint; | 9105 IPEndPoint endpoint; |
9106 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); | 9106 EXPECT_TRUE(trans->GetRemoteEndpoint(&endpoint)); |
9107 EXPECT_LT(0u, endpoint.address().size()); | 9107 EXPECT_LT(0u, endpoint.address().bytes().size()); |
9108 } | 9108 } |
9109 | 9109 |
9110 // Make sure that a dropped connection while draining the body for auth | 9110 // Make sure that a dropped connection while draining the body for auth |
9111 // restart does the right thing. | 9111 // restart does the right thing. |
9112 TEST_P(HttpNetworkTransactionTest, DrainResetOK) { | 9112 TEST_P(HttpNetworkTransactionTest, DrainResetOK) { |
9113 HttpRequestInfo request; | 9113 HttpRequestInfo request; |
9114 request.method = "GET"; | 9114 request.method = "GET"; |
9115 request.url = GURL("http://www.example.org/"); | 9115 request.url = GURL("http://www.example.org/"); |
9116 request.load_flags = 0; | 9116 request.load_flags = 0; |
9117 | 9117 |
(...skipping 6678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15796 | 15796 |
15797 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 15797 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
15798 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 15798 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
15799 | 15799 |
15800 EXPECT_THAT(trans.server_ssl_config_.alpn_protos, | 15800 EXPECT_THAT(trans.server_ssl_config_.alpn_protos, |
15801 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11)); | 15801 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11)); |
15802 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty()); | 15802 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty()); |
15803 } | 15803 } |
15804 | 15804 |
15805 } // namespace net | 15805 } // namespace net |
OLD | NEW |