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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 8418024: Don't convert HEAD requests to GETs on 303 redirects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix sync unit tests Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif 10 #endif
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 EXPECT_FALSE(ContainsString(data, "Content-Type:")); 2476 EXPECT_FALSE(ContainsString(data, "Content-Type:"));
2477 EXPECT_FALSE(ContainsString(data, "Origin:")); 2477 EXPECT_FALSE(ContainsString(data, "Origin:"));
2478 2478
2479 // These extra request headers should not have been stripped. 2479 // These extra request headers should not have been stripped.
2480 EXPECT_TRUE(ContainsString(data, "Accept:")); 2480 EXPECT_TRUE(ContainsString(data, "Accept:"));
2481 EXPECT_TRUE(ContainsString(data, "Accept-Language:")); 2481 EXPECT_TRUE(ContainsString(data, "Accept-Language:"));
2482 EXPECT_TRUE(ContainsString(data, "Accept-Charset:")); 2482 EXPECT_TRUE(ContainsString(data, "Accept-Charset:"));
2483 } 2483 }
2484 2484
2485 // The following tests check that we handle mutating the request method for 2485 // The following tests check that we handle mutating the request method for
2486 // HTTP redirects as expected. See http://crbug.com/56373. 2486 // HTTP redirects as expected.
2487 // See http://crbug.com/56373 and http://crbug.com/102130.
2487 2488
2488 TEST_F(URLRequestTestHTTP, Redirect301Tests) { 2489 TEST_F(URLRequestTestHTTP, Redirect301Tests) {
2489 ASSERT_TRUE(test_server_.Start()); 2490 ASSERT_TRUE(test_server_.Start());
2490 2491
2491 const GURL url = test_server_.GetURL("files/redirect301-to-echo"); 2492 const GURL url = test_server_.GetURL("files/redirect301-to-echo");
2492 2493
2493 HTTPRedirectMethodTest(url, "POST", "GET", true); 2494 HTTPRedirectMethodTest(url, "POST", "GET", true);
2494 HTTPRedirectMethodTest(url, "PUT", "PUT", true); 2495 HTTPRedirectMethodTest(url, "PUT", "PUT", true);
2496 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
2495 } 2497 }
2496 2498
2497 TEST_F(URLRequestTestHTTP, Redirect302Tests) { 2499 TEST_F(URLRequestTestHTTP, Redirect302Tests) {
2498 ASSERT_TRUE(test_server_.Start()); 2500 ASSERT_TRUE(test_server_.Start());
2499 2501
2500 const GURL url = test_server_.GetURL("files/redirect302-to-echo"); 2502 const GURL url = test_server_.GetURL("files/redirect302-to-echo");
2501 2503
2502 HTTPRedirectMethodTest(url, "POST", "GET", true); 2504 HTTPRedirectMethodTest(url, "POST", "GET", true);
2503 HTTPRedirectMethodTest(url, "PUT", "PUT", true); 2505 HTTPRedirectMethodTest(url, "PUT", "PUT", true);
2506 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
2504 } 2507 }
2505 2508
2506 TEST_F(URLRequestTestHTTP, Redirect303Tests) { 2509 TEST_F(URLRequestTestHTTP, Redirect303Tests) {
2507 ASSERT_TRUE(test_server_.Start()); 2510 ASSERT_TRUE(test_server_.Start());
2508 2511
2509 const GURL url = test_server_.GetURL("files/redirect303-to-echo"); 2512 const GURL url = test_server_.GetURL("files/redirect303-to-echo");
2510 2513
2511 HTTPRedirectMethodTest(url, "POST", "GET", true); 2514 HTTPRedirectMethodTest(url, "POST", "GET", true);
2512 HTTPRedirectMethodTest(url, "PUT", "GET", true); 2515 HTTPRedirectMethodTest(url, "PUT", "GET", true);
2516 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
2513 } 2517 }
2514 2518
2515 TEST_F(URLRequestTestHTTP, Redirect307Tests) { 2519 TEST_F(URLRequestTestHTTP, Redirect307Tests) {
2516 ASSERT_TRUE(test_server_.Start()); 2520 ASSERT_TRUE(test_server_.Start());
2517 2521
2518 const GURL url = test_server_.GetURL("files/redirect307-to-echo"); 2522 const GURL url = test_server_.GetURL("files/redirect307-to-echo");
2519 2523
2520 HTTPRedirectMethodTest(url, "POST", "POST", true); 2524 HTTPRedirectMethodTest(url, "POST", "POST", true);
2521 HTTPRedirectMethodTest(url, "PUT", "PUT", true); 2525 HTTPRedirectMethodTest(url, "PUT", "PUT", true);
2526 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
2522 } 2527 }
2523 2528
2524 TEST_F(URLRequestTestHTTP, InterceptPost302RedirectGet) { 2529 TEST_F(URLRequestTestHTTP, InterceptPost302RedirectGet) {
2525 ASSERT_TRUE(test_server_.Start()); 2530 ASSERT_TRUE(test_server_.Start());
2526 2531
2527 const char kData[] = "hello world"; 2532 const char kData[] = "hello world";
2528 2533
2529 TestDelegate d; 2534 TestDelegate d;
2530 TestURLRequest req(test_server_.GetURL("empty.html"), &d); 2535 TestURLRequest req(test_server_.GetURL("empty.html"), &d);
2531 req.set_context(default_context_); 2536 req.set_context(default_context_);
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
3630 req.SetExtraRequestHeaders(headers); 3635 req.SetExtraRequestHeaders(headers);
3631 req.Start(); 3636 req.Start();
3632 MessageLoop::current()->Run(); 3637 MessageLoop::current()->Run();
3633 // If the net tests are being run with ChromeFrame then we need to allow for 3638 // If the net tests are being run with ChromeFrame then we need to allow for
3634 // the 'chromeframe' suffix which is added to the user agent before the 3639 // the 'chromeframe' suffix which is added to the user agent before the
3635 // closing parentheses. 3640 // closing parentheses.
3636 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); 3641 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true));
3637 } 3642 }
3638 3643
3639 } // namespace net 3644 } // namespace net
OLDNEW
« net/tools/testserver/testserver.py ('K') | « net/url_request/url_request.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698