| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2545 ExpectLogContainsSomewhere( | 2545 ExpectLogContainsSomewhere( |
| 2546 entries, pos, | 2546 entries, pos, |
| 2547 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2547 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 2548 NetLog::PHASE_NONE); | 2548 NetLog::PHASE_NONE); |
| 2549 | 2549 |
| 2550 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2550 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2551 ASSERT_TRUE(response != NULL); | 2551 ASSERT_TRUE(response != NULL); |
| 2552 ASSERT_FALSE(response->headers.get() == NULL); | 2552 ASSERT_FALSE(response->headers.get() == NULL); |
| 2553 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2553 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 2554 EXPECT_EQ(407, response->headers->response_code()); | 2554 EXPECT_EQ(407, response->headers->response_code()); |
| 2555 EXPECT_EQ(10, response->headers->GetContentLength()); | |
| 2556 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2555 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2557 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2556 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2558 | 2557 |
| 2559 TestCompletionCallback callback2; | 2558 TestCompletionCallback callback2; |
| 2560 | 2559 |
| 2561 // Wrong password (should be "bar"). | 2560 // Wrong password (should be "bar"). |
| 2562 rv = trans->RestartWithAuth( | 2561 rv = trans->RestartWithAuth( |
| 2563 AuthCredentials(kFoo, kBaz), callback2.callback()); | 2562 AuthCredentials(kFoo, kBaz), callback2.callback()); |
| 2564 EXPECT_EQ(ERR_IO_PENDING, rv); | 2563 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2565 | 2564 |
| 2566 rv = callback2.WaitForResult(); | 2565 rv = callback2.WaitForResult(); |
| 2567 EXPECT_EQ(OK, rv); | 2566 EXPECT_EQ(OK, rv); |
| 2568 | 2567 |
| 2569 response = trans->GetResponseInfo(); | 2568 response = trans->GetResponseInfo(); |
| 2570 ASSERT_TRUE(response != NULL); | 2569 ASSERT_TRUE(response != NULL); |
| 2571 ASSERT_FALSE(response->headers.get() == NULL); | 2570 ASSERT_FALSE(response->headers.get() == NULL); |
| 2572 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2571 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 2573 EXPECT_EQ(407, response->headers->response_code()); | 2572 EXPECT_EQ(407, response->headers->response_code()); |
| 2574 EXPECT_EQ(10, response->headers->GetContentLength()); | |
| 2575 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2573 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2576 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2574 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2577 | 2575 |
| 2578 // Flush the idle socket before the NetLog and HttpNetworkTransaction go | 2576 // Flush the idle socket before the NetLog and HttpNetworkTransaction go |
| 2579 // out of scope. | 2577 // out of scope. |
| 2580 session->CloseAllConnections(); | 2578 session->CloseAllConnections(); |
| 2581 } | 2579 } |
| 2582 | 2580 |
| 2583 // Test that we don't read the response body when we fail to establish a tunnel, | 2581 // Test that we don't read the response body when we fail to establish a tunnel, |
| 2584 // even if the user cancels the proxy's auth attempt. | 2582 // even if the user cancels the proxy's auth attempt. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 EXPECT_EQ(ERR_IO_PENDING, rv); | 2619 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2622 | 2620 |
| 2623 rv = callback.WaitForResult(); | 2621 rv = callback.WaitForResult(); |
| 2624 EXPECT_EQ(OK, rv); | 2622 EXPECT_EQ(OK, rv); |
| 2625 | 2623 |
| 2626 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2624 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2627 ASSERT_TRUE(response != NULL); | 2625 ASSERT_TRUE(response != NULL); |
| 2628 | 2626 |
| 2629 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2627 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 2630 EXPECT_EQ(407, response->headers->response_code()); | 2628 EXPECT_EQ(407, response->headers->response_code()); |
| 2631 EXPECT_EQ(10, response->headers->GetContentLength()); | |
| 2632 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2629 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2633 | 2630 |
| 2634 std::string response_data; | 2631 std::string response_data; |
| 2635 rv = ReadTransaction(trans.get(), &response_data); | 2632 rv = ReadTransaction(trans.get(), &response_data); |
| 2636 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 2633 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 2637 | 2634 |
| 2638 // Flush the idle socket before the HttpNetworkTransaction goes out of scope. | 2635 // Flush the idle socket before the HttpNetworkTransaction goes out of scope. |
| 2639 session->CloseAllConnections(); | 2636 session->CloseAllConnections(); |
| 2640 } | 2637 } |
| 2641 | 2638 |
| (...skipping 10545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13187 EXPECT_EQ(ERR_IO_PENDING, rv); | 13184 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 13188 | 13185 |
| 13189 rv = callback.WaitForResult(); | 13186 rv = callback.WaitForResult(); |
| 13190 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 13187 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
| 13191 | 13188 |
| 13192 const HttpResponseInfo* response = trans->GetResponseInfo(); | 13189 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 13193 EXPECT_TRUE(response == NULL); | 13190 EXPECT_TRUE(response == NULL); |
| 13194 } | 13191 } |
| 13195 | 13192 |
| 13196 } // namespace net | 13193 } // namespace net |
| OLD | NEW |