| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 4245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4256 request.url = GURL("http://foo:b@r@www.google.com/"); | 4256 request.url = GURL("http://foo:b@r@www.google.com/"); |
| 4257 | 4257 |
| 4258 SessionDependencies session_deps; | 4258 SessionDependencies session_deps; |
| 4259 scoped_ptr<HttpTransaction> trans( | 4259 scoped_ptr<HttpTransaction> trans( |
| 4260 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4260 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4261 | 4261 |
| 4262 // The password contains an escaped character -- for this test to pass it | 4262 // The password contains an escaped character -- for this test to pass it |
| 4263 // will need to be unescaped by HttpNetworkTransaction. | 4263 // will need to be unescaped by HttpNetworkTransaction. |
| 4264 EXPECT_EQ("b%40r", request.url.password()); | 4264 EXPECT_EQ("b%40r", request.url.password()); |
| 4265 | 4265 |
| 4266 request.load_flags = LOAD_NORMAL; | 4266 request.load_flags = LOAD_NORMAL | LOAD_ENABLE_EMBEDDED_IDENTITY; |
| 4267 | 4267 |
| 4268 MockWrite data_writes1[] = { | 4268 MockWrite data_writes1[] = { |
| 4269 MockWrite("GET / HTTP/1.1\r\n" | 4269 MockWrite("GET / HTTP/1.1\r\n" |
| 4270 "Host: www.google.com\r\n" | 4270 "Host: www.google.com\r\n" |
| 4271 "Connection: keep-alive\r\n\r\n"), | 4271 "Connection: keep-alive\r\n\r\n"), |
| 4272 }; | 4272 }; |
| 4273 | 4273 |
| 4274 MockRead data_reads1[] = { | 4274 MockRead data_reads1[] = { |
| 4275 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 4275 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
| 4276 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 4276 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4330 | 4330 |
| 4331 // Test the request-challenge-retry sequence for basic auth when there is | 4331 // Test the request-challenge-retry sequence for basic auth when there is |
| 4332 // an incorrect identity in the URL. The identity from the URL should be used | 4332 // an incorrect identity in the URL. The identity from the URL should be used |
| 4333 // only once. | 4333 // only once. |
| 4334 TEST_F(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { | 4334 TEST_F(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { |
| 4335 HttpRequestInfo request; | 4335 HttpRequestInfo request; |
| 4336 request.method = "GET"; | 4336 request.method = "GET"; |
| 4337 // Note: the URL has a username:password in it. The password "baz" is | 4337 // Note: the URL has a username:password in it. The password "baz" is |
| 4338 // wrong (should be "bar"). | 4338 // wrong (should be "bar"). |
| 4339 request.url = GURL("http://foo:baz@www.google.com/"); | 4339 request.url = GURL("http://foo:baz@www.google.com/"); |
| 4340 | 4340 request.load_flags = LOAD_NORMAL | LOAD_ENABLE_EMBEDDED_IDENTITY; |
| 4341 request.load_flags = LOAD_NORMAL; | |
| 4342 | 4341 |
| 4343 SessionDependencies session_deps; | 4342 SessionDependencies session_deps; |
| 4344 scoped_ptr<HttpTransaction> trans( | 4343 scoped_ptr<HttpTransaction> trans( |
| 4345 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4344 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4346 | 4345 |
| 4347 MockWrite data_writes1[] = { | 4346 MockWrite data_writes1[] = { |
| 4348 MockWrite("GET / HTTP/1.1\r\n" | 4347 MockWrite("GET / HTTP/1.1\r\n" |
| 4349 "Host: www.google.com\r\n" | 4348 "Host: www.google.com\r\n" |
| 4350 "Connection: keep-alive\r\n\r\n"), | 4349 "Connection: keep-alive\r\n\r\n"), |
| 4351 }; | 4350 }; |
| (...skipping 5576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9928 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9927 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
| 9929 | 9928 |
| 9930 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9929 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
| 9931 | 9930 |
| 9932 EXPECT_EQ(OK, out.rv); | 9931 EXPECT_EQ(OK, out.rv); |
| 9933 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9932 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
| 9934 EXPECT_EQ("hello world", out.response_data); | 9933 EXPECT_EQ("hello world", out.response_data); |
| 9935 } | 9934 } |
| 9936 | 9935 |
| 9937 } // namespace net | 9936 } // namespace net |
| OLD | NEW |