| 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 4206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4217 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4217 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4218 | 4218 |
| 4219 // Setup some state (which we expect ResetStateForRestart() will clear). | 4219 // Setup some state (which we expect ResetStateForRestart() will clear). |
| 4220 trans->read_buf_ = new IOBuffer(15); | 4220 trans->read_buf_ = new IOBuffer(15); |
| 4221 trans->read_buf_len_ = 15; | 4221 trans->read_buf_len_ = 15; |
| 4222 trans->request_headers_.SetHeader("Authorization", "NTLM"); | 4222 trans->request_headers_.SetHeader("Authorization", "NTLM"); |
| 4223 | 4223 |
| 4224 // Setup state in response_ | 4224 // Setup state in response_ |
| 4225 HttpResponseInfo* response = &trans->response_; | 4225 HttpResponseInfo* response = &trans->response_; |
| 4226 response->auth_challenge = new AuthChallengeInfo(); | 4226 response->auth_challenge = new AuthChallengeInfo(); |
| 4227 response->ssl_info.cert_status = -15; | 4227 response->ssl_info.cert_status = static_cast<CertStatus>(-1); // Nonsensical. |
| 4228 response->response_time = base::Time::Now(); | 4228 response->response_time = base::Time::Now(); |
| 4229 response->was_cached = true; // (Wouldn't ever actually be true...) | 4229 response->was_cached = true; // (Wouldn't ever actually be true...) |
| 4230 | 4230 |
| 4231 { // Setup state for response_.vary_data | 4231 { // Setup state for response_.vary_data |
| 4232 HttpRequestInfo request; | 4232 HttpRequestInfo request; |
| 4233 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); | 4233 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); |
| 4234 std::replace(temp.begin(), temp.end(), '\n', '\0'); | 4234 std::replace(temp.begin(), temp.end(), '\n', '\0'); |
| 4235 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); | 4235 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); |
| 4236 request.extra_headers.SetHeader("Foo", "1"); | 4236 request.extra_headers.SetHeader("Foo", "1"); |
| 4237 request.extra_headers.SetHeader("bar", "23"); | 4237 request.extra_headers.SetHeader("bar", "23"); |
| 4238 EXPECT_TRUE(response->vary_data.Init(request, *headers)); | 4238 EXPECT_TRUE(response->vary_data.Init(request, *headers)); |
| 4239 } | 4239 } |
| 4240 | 4240 |
| 4241 // Cause the above state to be reset. | 4241 // Cause the above state to be reset. |
| 4242 trans->ResetStateForRestart(); | 4242 trans->ResetStateForRestart(); |
| 4243 | 4243 |
| 4244 // Verify that the state that needed to be reset, has been reset. | 4244 // Verify that the state that needed to be reset, has been reset. |
| 4245 EXPECT_TRUE(trans->read_buf_.get() == NULL); | 4245 EXPECT_TRUE(trans->read_buf_.get() == NULL); |
| 4246 EXPECT_EQ(0, trans->read_buf_len_); | 4246 EXPECT_EQ(0, trans->read_buf_len_); |
| 4247 EXPECT_TRUE(trans->request_headers_.IsEmpty()); | 4247 EXPECT_TRUE(trans->request_headers_.IsEmpty()); |
| 4248 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4248 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4249 EXPECT_TRUE(response->headers.get() == NULL); | 4249 EXPECT_TRUE(response->headers.get() == NULL); |
| 4250 EXPECT_FALSE(response->was_cached); | 4250 EXPECT_FALSE(response->was_cached); |
| 4251 EXPECT_EQ(0, response->ssl_info.cert_status); | 4251 EXPECT_EQ(CERT_STATUS_NO_ERROR, response->ssl_info.cert_status); |
| 4252 EXPECT_FALSE(response->vary_data.is_valid()); | 4252 EXPECT_FALSE(response->vary_data.is_valid()); |
| 4253 } | 4253 } |
| 4254 | 4254 |
| 4255 // Test HTTPS connections to a site with a bad certificate | 4255 // Test HTTPS connections to a site with a bad certificate |
| 4256 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) { | 4256 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) { |
| 4257 HttpRequestInfo request; | 4257 HttpRequestInfo request; |
| 4258 request.method = "GET"; | 4258 request.method = "GET"; |
| 4259 request.url = GURL("https://www.google.com/"); | 4259 request.url = GURL("https://www.google.com/"); |
| 4260 request.load_flags = 0; | 4260 request.load_flags = 0; |
| 4261 | 4261 |
| (...skipping 4633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8895 EXPECT_TRUE(response->was_fetched_via_spdy); | 8895 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 8896 EXPECT_TRUE(response->was_npn_negotiated); | 8896 EXPECT_TRUE(response->was_npn_negotiated); |
| 8897 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 8897 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 8898 EXPECT_EQ("hello!", response_data); | 8898 EXPECT_EQ("hello!", response_data); |
| 8899 | 8899 |
| 8900 HttpStreamFactory::set_next_protos(""); | 8900 HttpStreamFactory::set_next_protos(""); |
| 8901 HttpStreamFactory::set_use_alternate_protocols(false); | 8901 HttpStreamFactory::set_use_alternate_protocols(false); |
| 8902 } | 8902 } |
| 8903 | 8903 |
| 8904 } // namespace net | 8904 } // namespace net |
| OLD | NEW |