| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <math.h> // ceil | 5 #include <math.h> // ceil |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "net/base/client_socket_factory.h" | 8 #include "net/base/client_socket_factory.h" |
| 9 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
| 10 #include "net/base/upload_data.h" | 10 #include "net/base/upload_data.h" |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 591 |
| 592 EXPECT_TRUE(response->headers != NULL); | 592 EXPECT_TRUE(response->headers != NULL); |
| 593 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 593 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 594 | 594 |
| 595 std::string response_data; | 595 std::string response_data; |
| 596 rv = ReadTransaction(trans.get(), &response_data); | 596 rv = ReadTransaction(trans.get(), &response_data); |
| 597 EXPECT_EQ(net::OK, rv); | 597 EXPECT_EQ(net::OK, rv); |
| 598 EXPECT_EQ("hello world", response_data); | 598 EXPECT_EQ("hello world", response_data); |
| 599 } | 599 } |
| 600 | 600 |
| 601 // This test is almost the same as Ignores100 above, but the response contains |
| 602 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is |
| 603 // HTTP/1.1. |
| 604 TEST_F(HttpNetworkTransactionTest, Ignores1xx) { |
| 605 scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); |
| 606 scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( |
| 607 CreateSession(proxy_service.get()), &mock_socket_factory)); |
| 608 |
| 609 net::HttpRequestInfo request; |
| 610 request.method = "GET"; |
| 611 request.url = GURL("http://www.foo.com/"); |
| 612 request.load_flags = 0; |
| 613 |
| 614 MockRead data_reads[] = { |
| 615 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"), |
| 616 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 617 MockRead("hello world"), |
| 618 MockRead(false, net::OK), |
| 619 }; |
| 620 MockSocket data; |
| 621 data.reads = data_reads; |
| 622 mock_sockets[0] = &data; |
| 623 mock_sockets[1] = NULL; |
| 624 |
| 625 TestCompletionCallback callback; |
| 626 |
| 627 int rv = trans->Start(&request, &callback); |
| 628 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 629 |
| 630 rv = callback.WaitForResult(); |
| 631 EXPECT_EQ(net::OK, rv); |
| 632 |
| 633 const net::HttpResponseInfo* response = trans->GetResponseInfo(); |
| 634 EXPECT_TRUE(response != NULL); |
| 635 |
| 636 EXPECT_TRUE(response->headers != NULL); |
| 637 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 638 |
| 639 std::string response_data; |
| 640 rv = ReadTransaction(trans.get(), &response_data); |
| 641 EXPECT_EQ(net::OK, rv); |
| 642 EXPECT_EQ("hello world", response_data); |
| 643 } |
| 644 |
| 601 // read_failure specifies a read failure that should cause the network | 645 // read_failure specifies a read failure that should cause the network |
| 602 // transaction to resend the request. | 646 // transaction to resend the request. |
| 603 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( | 647 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( |
| 604 const MockRead& read_failure) { | 648 const MockRead& read_failure) { |
| 605 scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); | 649 scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); |
| 606 scoped_refptr<net::HttpNetworkSession> session = | 650 scoped_refptr<net::HttpNetworkSession> session = |
| 607 CreateSession(proxy_service.get()); | 651 CreateSession(proxy_service.get()); |
| 608 | 652 |
| 609 net::HttpRequestInfo request; | 653 net::HttpRequestInfo request; |
| 610 request.method = "GET"; | 654 request.method = "GET"; |
| (...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2613 EXPECT_EQ(NULL, trans->response_.auth_challenge.get()); | 2657 EXPECT_EQ(NULL, trans->response_.auth_challenge.get()); |
| 2614 EXPECT_EQ(NULL, trans->response_.headers.get()); | 2658 EXPECT_EQ(NULL, trans->response_.headers.get()); |
| 2615 EXPECT_EQ(false, trans->response_.was_cached); | 2659 EXPECT_EQ(false, trans->response_.was_cached); |
| 2616 EXPECT_EQ(base::kInvalidPlatformFileValue, | 2660 EXPECT_EQ(base::kInvalidPlatformFileValue, |
| 2617 trans->response_.response_data_file); | 2661 trans->response_.response_data_file); |
| 2618 EXPECT_EQ(0, trans->response_.ssl_info.cert_status); | 2662 EXPECT_EQ(0, trans->response_.ssl_info.cert_status); |
| 2619 EXPECT_FALSE(trans->response_.vary_data.is_valid()); | 2663 EXPECT_FALSE(trans->response_.vary_data.is_valid()); |
| 2620 } | 2664 } |
| 2621 | 2665 |
| 2622 } // namespace net | 2666 } // namespace net |
| OLD | NEW |