Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 1039001: HttpRequestHeaders refactor. (Closed)
Patch Set: Fix bugs, add tests. Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_request_headers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 3360
3361 TestCompletionCallback callback; 3361 TestCompletionCallback callback;
3362 3362
3363 int rv = trans->Start(&request, &callback, NULL); 3363 int rv = trans->Start(&request, &callback, NULL);
3364 EXPECT_EQ(ERR_IO_PENDING, rv); 3364 EXPECT_EQ(ERR_IO_PENDING, rv);
3365 3365
3366 rv = callback.WaitForResult(); 3366 rv = callback.WaitForResult();
3367 EXPECT_EQ(OK, rv); 3367 EXPECT_EQ(OK, rv);
3368 } 3368 }
3369 3369
3370 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) {
3371 SessionDependencies session_deps;
3372 scoped_ptr<HttpTransaction> trans(
3373 new HttpNetworkTransaction(CreateSession(&session_deps)));
3374
3375 HttpRequestInfo request;
3376 request.method = "GET";
3377 request.url = GURL("http://www.google.com/");
3378 request.extra_headers = "referer: www.foo.com\nhEllo: Kitty\rFoO: bar\r\n";
3379
3380 MockWrite data_writes[] = {
3381 MockWrite("GET / HTTP/1.1\r\n"
3382 "Host: www.google.com\r\n"
3383 "Connection: keep-alive\r\n"
3384 "hEllo: Kitty\r\n"
3385 "FoO: bar\r\n\r\n"),
3386 };
3387
3388 // Lastly, the server responds with the actual content.
3389 MockRead data_reads[] = {
3390 MockRead("HTTP/1.0 200 OK\r\n"),
3391 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3392 MockRead("Content-Length: 100\r\n\r\n"),
3393 MockRead(false, OK),
3394 };
3395
3396 StaticSocketDataProvider data(data_reads, arraysize(data_reads),
3397 data_writes, arraysize(data_writes));
3398 session_deps.socket_factory.AddSocketDataProvider(&data);
3399
3400 TestCompletionCallback callback;
3401
3402 int rv = trans->Start(&request, &callback, NULL);
3403 EXPECT_EQ(ERR_IO_PENDING, rv);
3404
3405 rv = callback.WaitForResult();
3406 EXPECT_EQ(OK, rv);
3407 }
3408
3370 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) { 3409 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) {
3371 SessionDependencies session_deps( 3410 SessionDependencies session_deps(
3372 CreateFixedProxyService("socks4://myproxy:1080")); 3411 CreateFixedProxyService("socks4://myproxy:1080"));
3373 3412
3374 scoped_ptr<HttpTransaction> trans( 3413 scoped_ptr<HttpTransaction> trans(
3375 new HttpNetworkTransaction(CreateSession(&session_deps))); 3414 new HttpNetworkTransaction(CreateSession(&session_deps)));
3376 3415
3377 HttpRequestInfo request; 3416 HttpRequestInfo request;
3378 request.method = "GET"; 3417 request.method = "GET";
3379 request.url = GURL("http://www.google.com/"); 3418 request.url = GURL("http://www.google.com/");
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
4472 ASSERT_TRUE(response != NULL); 4511 ASSERT_TRUE(response != NULL);
4473 ASSERT_TRUE(response->headers != NULL); 4512 ASSERT_TRUE(response->headers != NULL);
4474 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 4513 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
4475 4514
4476 std::string response_data; 4515 std::string response_data;
4477 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 4516 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
4478 EXPECT_EQ("hello world", response_data); 4517 EXPECT_EQ("hello world", response_data);
4479 } 4518 }
4480 4519
4481 } // namespace net 4520 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_request_headers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698