OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 4308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4319 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4319 new HttpNetworkTransaction(CreateSession(&session_deps))); |
4320 | 4320 |
4321 // Setup some state (which we expect ResetStateForRestart() will clear). | 4321 // Setup some state (which we expect ResetStateForRestart() will clear). |
4322 trans->read_buf_ = new IOBuffer(15); | 4322 trans->read_buf_ = new IOBuffer(15); |
4323 trans->read_buf_len_ = 15; | 4323 trans->read_buf_len_ = 15; |
4324 trans->request_headers_.SetHeader("Authorization", "NTLM"); | 4324 trans->request_headers_.SetHeader("Authorization", "NTLM"); |
4325 | 4325 |
4326 // Setup state in response_ | 4326 // Setup state in response_ |
4327 HttpResponseInfo* response = &trans->response_; | 4327 HttpResponseInfo* response = &trans->response_; |
4328 response->auth_challenge = new AuthChallengeInfo(); | 4328 response->auth_challenge = new AuthChallengeInfo(); |
4329 response->ssl_info.cert_status = -15; | 4329 response->ssl_info.cert_status = static_cast<CertStatus>(-15); |
4330 response->response_time = base::Time::Now(); | 4330 response->response_time = base::Time::Now(); |
4331 response->was_cached = true; // (Wouldn't ever actually be true...) | 4331 response->was_cached = true; // (Wouldn't ever actually be true...) |
4332 | 4332 |
4333 { // Setup state for response_.vary_data | 4333 { // Setup state for response_.vary_data |
4334 HttpRequestInfo request; | 4334 HttpRequestInfo request; |
4335 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); | 4335 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); |
4336 std::replace(temp.begin(), temp.end(), '\n', '\0'); | 4336 std::replace(temp.begin(), temp.end(), '\n', '\0'); |
4337 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); | 4337 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); |
4338 request.extra_headers.SetHeader("Foo", "1"); | 4338 request.extra_headers.SetHeader("Foo", "1"); |
4339 request.extra_headers.SetHeader("bar", "23"); | 4339 request.extra_headers.SetHeader("bar", "23"); |
4340 EXPECT_TRUE(response->vary_data.Init(request, *headers)); | 4340 EXPECT_TRUE(response->vary_data.Init(request, *headers)); |
4341 } | 4341 } |
4342 | 4342 |
4343 // Cause the above state to be reset. | 4343 // Cause the above state to be reset. |
4344 trans->ResetStateForRestart(); | 4344 trans->ResetStateForRestart(); |
4345 | 4345 |
4346 // Verify that the state that needed to be reset, has been reset. | 4346 // Verify that the state that needed to be reset, has been reset. |
4347 EXPECT_TRUE(trans->read_buf_.get() == NULL); | 4347 EXPECT_TRUE(trans->read_buf_.get() == NULL); |
4348 EXPECT_EQ(0, trans->read_buf_len_); | 4348 EXPECT_EQ(0, trans->read_buf_len_); |
4349 EXPECT_TRUE(trans->request_headers_.IsEmpty()); | 4349 EXPECT_TRUE(trans->request_headers_.IsEmpty()); |
4350 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4350 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4351 EXPECT_TRUE(response->headers.get() == NULL); | 4351 EXPECT_TRUE(response->headers.get() == NULL); |
4352 EXPECT_FALSE(response->was_cached); | 4352 EXPECT_FALSE(response->was_cached); |
4353 EXPECT_EQ(0, response->ssl_info.cert_status); | 4353 EXPECT_EQ(CERT_STATUS_NO_ERROR, response->ssl_info.cert_status); |
4354 EXPECT_FALSE(response->vary_data.is_valid()); | 4354 EXPECT_FALSE(response->vary_data.is_valid()); |
4355 } | 4355 } |
4356 | 4356 |
4357 // Test HTTPS connections to a site with a bad certificate | 4357 // Test HTTPS connections to a site with a bad certificate |
4358 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) { | 4358 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) { |
4359 HttpRequestInfo request; | 4359 HttpRequestInfo request; |
4360 request.method = "GET"; | 4360 request.method = "GET"; |
4361 request.url = GURL("https://www.google.com/"); | 4361 request.url = GURL("https://www.google.com/"); |
4362 request.load_flags = 0; | 4362 request.load_flags = 0; |
4363 | 4363 |
(...skipping 4638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9002 EXPECT_TRUE(response->was_fetched_via_spdy); | 9002 EXPECT_TRUE(response->was_fetched_via_spdy); |
9003 EXPECT_TRUE(response->was_npn_negotiated); | 9003 EXPECT_TRUE(response->was_npn_negotiated); |
9004 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 9004 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
9005 EXPECT_EQ("hello!", response_data); | 9005 EXPECT_EQ("hello!", response_data); |
9006 | 9006 |
9007 HttpStreamFactory::set_next_protos(""); | 9007 HttpStreamFactory::set_next_protos(""); |
9008 HttpStreamFactory::set_use_alternate_protocols(false); | 9008 HttpStreamFactory::set_use_alternate_protocols(false); |
9009 } | 9009 } |
9010 | 9010 |
9011 } // namespace net | 9011 } // namespace net |
OLD | NEW |