OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 3361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3372 | 3372 |
3373 TestCompletionCallback callback; | 3373 TestCompletionCallback callback; |
3374 | 3374 |
3375 int rv = trans->Start(&request, &callback, NULL); | 3375 int rv = trans->Start(&request, &callback, NULL); |
3376 EXPECT_EQ(ERR_IO_PENDING, rv); | 3376 EXPECT_EQ(ERR_IO_PENDING, rv); |
3377 | 3377 |
3378 rv = callback.WaitForResult(); | 3378 rv = callback.WaitForResult(); |
3379 EXPECT_EQ(OK, rv); | 3379 EXPECT_EQ(OK, rv); |
3380 } | 3380 } |
3381 | 3381 |
3382 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) { | |
3383 SessionDependencies session_deps; | |
3384 scoped_ptr<HttpTransaction> trans( | |
3385 new HttpNetworkTransaction(CreateSession(&session_deps))); | |
3386 | |
3387 HttpRequestInfo request; | |
3388 request.method = "GET"; | |
3389 request.url = GURL("http://www.google.com/"); | |
3390 request.extra_headers = "referer: www.foo.com\nhEllo: Kitty\rFoO: bar\r\n"; | |
3391 | |
3392 MockWrite data_writes[] = { | |
3393 MockWrite("GET / HTTP/1.1\r\n" | |
3394 "Host: www.google.com\r\n" | |
3395 "Connection: keep-alive\r\n" | |
3396 "hEllo: Kitty\r\n" | |
3397 "FoO: bar\r\n\r\n"), | |
3398 }; | |
3399 | |
3400 // Lastly, the server responds with the actual content. | |
3401 MockRead data_reads[] = { | |
3402 MockRead("HTTP/1.0 200 OK\r\n"), | |
3403 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | |
3404 MockRead("Content-Length: 100\r\n\r\n"), | |
3405 MockRead(false, OK), | |
3406 }; | |
3407 | |
3408 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | |
3409 data_writes, arraysize(data_writes)); | |
3410 session_deps.socket_factory.AddSocketDataProvider(&data); | |
3411 | |
3412 TestCompletionCallback callback; | |
3413 | |
3414 int rv = trans->Start(&request, &callback, NULL); | |
3415 EXPECT_EQ(ERR_IO_PENDING, rv); | |
3416 | |
3417 rv = callback.WaitForResult(); | |
3418 EXPECT_EQ(OK, rv); | |
3419 } | |
3420 | |
3421 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) { | 3382 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) { |
3422 SessionDependencies session_deps( | 3383 SessionDependencies session_deps( |
3423 CreateFixedProxyService("socks4://myproxy:1080")); | 3384 CreateFixedProxyService("socks4://myproxy:1080")); |
3424 | 3385 |
3425 scoped_ptr<HttpTransaction> trans( | 3386 scoped_ptr<HttpTransaction> trans( |
3426 new HttpNetworkTransaction(CreateSession(&session_deps))); | 3387 new HttpNetworkTransaction(CreateSession(&session_deps))); |
3427 | 3388 |
3428 HttpRequestInfo request; | 3389 HttpRequestInfo request; |
3429 request.method = "GET"; | 3390 request.method = "GET"; |
3430 request.url = GURL("http://www.google.com/"); | 3391 request.url = GURL("http://www.google.com/"); |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4529 ASSERT_TRUE(response != NULL); | 4490 ASSERT_TRUE(response != NULL); |
4530 ASSERT_TRUE(response->headers != NULL); | 4491 ASSERT_TRUE(response->headers != NULL); |
4531 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4492 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4532 | 4493 |
4533 std::string response_data; | 4494 std::string response_data; |
4534 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4495 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
4535 EXPECT_EQ("hello world", response_data); | 4496 EXPECT_EQ("hello world", response_data); |
4536 } | 4497 } |
4537 | 4498 |
4538 } // namespace net | 4499 } // namespace net |
OLD | NEW |