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

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

Issue 154473002: Support redirectUrl at onHeadersReceived in WebRequest / DWR API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clarify documentation Created 6 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/url_request/url_request_test_util.cc ('k') | no next file » | 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) 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 GURL* new_url) OVERRIDE; 361 GURL* new_url) OVERRIDE;
362 362
363 virtual int OnBeforeSendHeaders(URLRequest* request, 363 virtual int OnBeforeSendHeaders(URLRequest* request,
364 const CompletionCallback& callback, 364 const CompletionCallback& callback,
365 HttpRequestHeaders* headers) OVERRIDE; 365 HttpRequestHeaders* headers) OVERRIDE;
366 366
367 virtual int OnHeadersReceived( 367 virtual int OnHeadersReceived(
368 URLRequest* request, 368 URLRequest* request,
369 const CompletionCallback& callback, 369 const CompletionCallback& callback,
370 const HttpResponseHeaders* original_response_headers, 370 const HttpResponseHeaders* original_response_headers,
371 scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE; 371 scoped_refptr<HttpResponseHeaders>* override_response_headers,
372 GURL* allowed_unsafe_redirect_url) OVERRIDE;
372 373
373 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( 374 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired(
374 URLRequest* request, 375 URLRequest* request,
375 const AuthChallengeInfo& auth_info, 376 const AuthChallengeInfo& auth_info,
376 const AuthCallback& callback, 377 const AuthCallback& callback,
377 AuthCredentials* credentials) OVERRIDE; 378 AuthCredentials* credentials) OVERRIDE;
378 379
379 // Resets the callbacks and |stage_blocked_for_callback_|. 380 // Resets the callbacks and |stage_blocked_for_callback_|.
380 void Reset(); 381 void Reset();
381 382
382 // Checks whether we should block in |stage|. If yes, returns an error code 383 // Checks whether we should block in |stage|. If yes, returns an error code
383 // and optionally sets up callback based on |block_mode_|. If no, returns OK. 384 // and optionally sets up callback based on |block_mode_|. If no, returns OK.
384 int MaybeBlockStage(Stage stage, const CompletionCallback& callback); 385 int MaybeBlockStage(Stage stage, const CompletionCallback& callback);
385 386
386 // Configuration parameters, can be adjusted by public methods: 387 // Configuration parameters, can be adjusted by public methods:
387 const BlockMode block_mode_; 388 const BlockMode block_mode_;
388 389
389 // Values returned on blocking stages when mode is SYNCHRONOUS or 390 // Values returned on blocking stages when mode is SYNCHRONOUS or
390 // AUTO_CALLBACK. For USER_CALLBACK these are set automatically to IO_PENDING. 391 // AUTO_CALLBACK. For USER_CALLBACK these are set automatically to IO_PENDING.
391 int retval_; // To be returned in non-auth stages. 392 int retval_; // To be returned in non-auth stages.
392 AuthRequiredResponse auth_retval_; 393 AuthRequiredResponse auth_retval_;
393 394
394 GURL redirect_url_; // Used if non-empty. 395 GURL redirect_url_; // Used if non-empty during OnBeforeURLRequest.
395 int block_on_; // Bit mask: in which stages to block. 396 int block_on_; // Bit mask: in which stages to block.
396 397
397 // |auth_credentials_| will be copied to |*target_auth_credential_| on 398 // |auth_credentials_| will be copied to |*target_auth_credential_| on
398 // callback. 399 // callback.
399 AuthCredentials auth_credentials_; 400 AuthCredentials auth_credentials_;
400 AuthCredentials* target_auth_credentials_; 401 AuthCredentials* target_auth_credentials_;
401 402
402 // Internal variables, not set by not the user: 403 // Internal variables, not set by not the user:
403 // Last blocked stage waiting for user callback (unused if |block_mode_| != 404 // Last blocked stage waiting for user callback (unused if |block_mode_| !=
404 // USER_CALLBACK). 405 // USER_CALLBACK).
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 HttpRequestHeaders* headers) { 477 HttpRequestHeaders* headers) {
477 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers); 478 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers);
478 479
479 return MaybeBlockStage(ON_BEFORE_SEND_HEADERS, callback); 480 return MaybeBlockStage(ON_BEFORE_SEND_HEADERS, callback);
480 } 481 }
481 482
482 int BlockingNetworkDelegate::OnHeadersReceived( 483 int BlockingNetworkDelegate::OnHeadersReceived(
483 URLRequest* request, 484 URLRequest* request,
484 const CompletionCallback& callback, 485 const CompletionCallback& callback,
485 const HttpResponseHeaders* original_response_headers, 486 const HttpResponseHeaders* original_response_headers,
486 scoped_refptr<HttpResponseHeaders>* override_response_headers) { 487 scoped_refptr<HttpResponseHeaders>* override_response_headers,
487 TestNetworkDelegate::OnHeadersReceived( 488 GURL* allowed_unsafe_redirect_url) {
488 request, callback, original_response_headers, 489 TestNetworkDelegate::OnHeadersReceived(request,
489 override_response_headers); 490 callback,
491 original_response_headers,
492 override_response_headers,
493 allowed_unsafe_redirect_url);
490 494
491 return MaybeBlockStage(ON_HEADERS_RECEIVED, callback); 495 return MaybeBlockStage(ON_HEADERS_RECEIVED, callback);
492 } 496 }
493 497
494 NetworkDelegate::AuthRequiredResponse BlockingNetworkDelegate::OnAuthRequired( 498 NetworkDelegate::AuthRequiredResponse BlockingNetworkDelegate::OnAuthRequired(
495 URLRequest* request, 499 URLRequest* request,
496 const AuthChallengeInfo& auth_info, 500 const AuthChallengeInfo& auth_info,
497 const AuthCallback& callback, 501 const AuthCallback& callback,
498 AuthCredentials* credentials) { 502 AuthCredentials* credentials) {
499 TestNetworkDelegate::OnAuthRequired(request, auth_info, callback, 503 TestNetworkDelegate::OnAuthRequired(request, auth_info, callback,
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 public: 2414 public:
2411 explicit FixedDateNetworkDelegate(const std::string& fixed_date) 2415 explicit FixedDateNetworkDelegate(const std::string& fixed_date)
2412 : fixed_date_(fixed_date) {} 2416 : fixed_date_(fixed_date) {}
2413 virtual ~FixedDateNetworkDelegate() {} 2417 virtual ~FixedDateNetworkDelegate() {}
2414 2418
2415 // net::NetworkDelegate implementation 2419 // net::NetworkDelegate implementation
2416 virtual int OnHeadersReceived( 2420 virtual int OnHeadersReceived(
2417 net::URLRequest* request, 2421 net::URLRequest* request,
2418 const net::CompletionCallback& callback, 2422 const net::CompletionCallback& callback,
2419 const net::HttpResponseHeaders* original_response_headers, 2423 const net::HttpResponseHeaders* original_response_headers,
2420 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) 2424 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
2421 OVERRIDE; 2425 GURL* allowed_unsafe_redirect_url) OVERRIDE;
2422 2426
2423 private: 2427 private:
2424 std::string fixed_date_; 2428 std::string fixed_date_;
2425 2429
2426 DISALLOW_COPY_AND_ASSIGN(FixedDateNetworkDelegate); 2430 DISALLOW_COPY_AND_ASSIGN(FixedDateNetworkDelegate);
2427 }; 2431 };
2428 2432
2429 int FixedDateNetworkDelegate::OnHeadersReceived( 2433 int FixedDateNetworkDelegate::OnHeadersReceived(
2430 net::URLRequest* request, 2434 net::URLRequest* request,
2431 const net::CompletionCallback& callback, 2435 const net::CompletionCallback& callback,
2432 const net::HttpResponseHeaders* original_response_headers, 2436 const net::HttpResponseHeaders* original_response_headers,
2433 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) { 2437 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
2438 GURL* allowed_unsafe_redirect_url) {
2434 net::HttpResponseHeaders* new_response_headers = 2439 net::HttpResponseHeaders* new_response_headers =
2435 new net::HttpResponseHeaders(original_response_headers->raw_headers()); 2440 new net::HttpResponseHeaders(original_response_headers->raw_headers());
2436 2441
2437 new_response_headers->RemoveHeader("Date"); 2442 new_response_headers->RemoveHeader("Date");
2438 new_response_headers->AddHeader("Date: " + fixed_date_); 2443 new_response_headers->AddHeader("Date: " + fixed_date_);
2439 2444
2440 *override_response_headers = new_response_headers; 2445 *override_response_headers = new_response_headers;
2441 return TestNetworkDelegate::OnHeadersReceived(request, 2446 return TestNetworkDelegate::OnHeadersReceived(request,
2442 callback, 2447 callback,
2443 original_response_headers, 2448 original_response_headers,
2444 override_response_headers); 2449 override_response_headers,
2450 allowed_unsafe_redirect_url);
2445 } 2451 }
2446 2452
2447 // Test that cookie expiration times are adjusted for server/client clock 2453 // Test that cookie expiration times are adjusted for server/client clock
2448 // skew and that we handle incorrect timezone specifier "UTC" in HTTP Date 2454 // skew and that we handle incorrect timezone specifier "UTC" in HTTP Date
2449 // headers by defaulting to GMT. (crbug.com/135131) 2455 // headers by defaulting to GMT. (crbug.com/135131)
2450 TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) { 2456 TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) {
2451 LocalHttpTestServer test_server; 2457 LocalHttpTestServer test_server;
2452 ASSERT_TRUE(test_server.Start()); 2458 ASSERT_TRUE(test_server.Start());
2453 2459
2454 // Set up an expired cookie. 2460 // Set up an expired cookie.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 EXPECT_TRUE(test_server_.Stop()); 2696 EXPECT_TRUE(test_server_.Stop());
2691 EXPECT_TRUE(test_server_.Start()); 2697 EXPECT_TRUE(test_server_.Start());
2692 } 2698 }
2693 2699
2694 return is_success; 2700 return is_success;
2695 } 2701 }
2696 2702
2697 LocalHttpTestServer test_server_; 2703 LocalHttpTestServer test_server_;
2698 }; 2704 };
2699 2705
2706 // Tests that redirection to an unsafe URL is allowed when it has been marked as
2707 // safe.
2708 TEST_F(URLRequestTestHTTP, UnsafeRedirectToWhitelistedUnsafeURL) {
2709 ASSERT_TRUE(test_server_.Start());
2710
2711 GURL unsafe_url("data:text/html,this-is-considered-an-unsafe-url");
2712 default_network_delegate_.set_redirect_on_headers_received_url(unsafe_url);
2713 default_network_delegate_.set_allowed_unsafe_redirect_url(unsafe_url);
2714
2715 TestDelegate d;
2716 {
2717 URLRequest r(test_server_.GetURL("whatever"),
2718 DEFAULT_PRIORITY,
2719 &d,
2720 &default_context_);
2721
2722 r.Start();
2723 base::RunLoop().Run();
2724
2725 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
2726
2727 EXPECT_EQ(2U, r.url_chain().size());
2728 EXPECT_EQ(0, r.status().error());
mmenke 2014/03/25 15:08:34 This should be net::OK instead of 0.
robwu 2014/03/25 15:59:35 Done.
2729 EXPECT_EQ(unsafe_url, r.url());
mmenke 2014/03/25 15:08:34 Suggest checking the body, for completeness.
robwu 2014/03/25 15:59:35 Done.
2730 }
2731 }
2732
2733 // Tests that a redirect to a different unsafe URL is blocked, even after adding
2734 // some other URL to the whitelist.
2735 TEST_F(URLRequestTestHTTP, UnsafeRedirectToDifferentUnsafeURL) {
2736 ASSERT_TRUE(test_server_.Start());
2737
2738 GURL unsafe_url("data:text/html,something");
2739 GURL different_unsafe_url("data:text/html,something-else");
2740 default_network_delegate_.set_redirect_on_headers_received_url(unsafe_url);
2741 default_network_delegate_.set_allowed_unsafe_redirect_url(
2742 different_unsafe_url);
2743
2744 TestDelegate d;
2745 {
2746 URLRequest r(test_server_.GetURL("whatever"),
2747 DEFAULT_PRIORITY,
2748 &d,
2749 &default_context_);
2750
2751 r.Start();
2752 base::RunLoop().Run();
2753
2754 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
2755 EXPECT_EQ(ERR_UNSAFE_REDIRECT, r.status().error());
2756 }
2757 }
mmenke 2014/03/25 15:08:34 Sorry, there were two parts to my comment (I shoul
robwu 2014/03/25 15:59:35 Done.
2758
2700 // In this unit test, we're using the HTTPTestServer as a proxy server and 2759 // In this unit test, we're using the HTTPTestServer as a proxy server and
2701 // issuing a CONNECT request with the magic host name "www.redirect.com". 2760 // issuing a CONNECT request with the magic host name "www.redirect.com".
2702 // The HTTPTestServer will return a 302 response, which we should not 2761 // The HTTPTestServer will return a 302 response, which we should not
2703 // follow. 2762 // follow.
2704 TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) { 2763 TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) {
2705 ASSERT_TRUE(test_server_.Start()); 2764 ASSERT_TRUE(test_server_.Start());
2706 2765
2707 TestNetworkDelegate network_delegate; // Must outlive URLRequest. 2766 TestNetworkDelegate network_delegate; // Must outlive URLRequest.
2708 TestURLRequestContextWithProxy context( 2767 TestURLRequestContextWithProxy context(
2709 test_server_.host_port_pair().ToString(), &network_delegate); 2768 test_server_.host_port_pair().ToString(), &network_delegate);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 EXPECT_EQ(original_url, r.original_url()); 3060 EXPECT_EQ(original_url, r.original_url());
3002 EXPECT_EQ(2U, r.url_chain().size()); 3061 EXPECT_EQ(2U, r.url_chain().size());
3003 EXPECT_EQ(1, network_delegate.created_requests()); 3062 EXPECT_EQ(1, network_delegate.created_requests());
3004 EXPECT_EQ(0, network_delegate.destroyed_requests()); 3063 EXPECT_EQ(0, network_delegate.destroyed_requests());
3005 EXPECT_EQ("POST", r.method()); 3064 EXPECT_EQ("POST", r.method());
3006 EXPECT_EQ(kData, d.data_received()); 3065 EXPECT_EQ(kData, d.data_received());
3007 } 3066 }
3008 EXPECT_EQ(1, network_delegate.destroyed_requests()); 3067 EXPECT_EQ(1, network_delegate.destroyed_requests());
3009 } 3068 }
3010 3069
3070 // Tests that the network delegate can block and redirect a request to a new
3071 // URL during OnHeadersReceived.
3072 TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestOnHeadersReceived) {
3073 ASSERT_TRUE(test_server_.Start());
3074
3075 TestDelegate d;
3076 BlockingNetworkDelegate network_delegate(
3077 BlockingNetworkDelegate::AUTO_CALLBACK);
3078 network_delegate.set_block_on(BlockingNetworkDelegate::ON_HEADERS_RECEIVED);
3079 GURL redirect_url(test_server_.GetURL("simple.html"));
3080 network_delegate.set_redirect_on_headers_received_url(redirect_url);
3081
3082 TestURLRequestContextWithProxy context(
3083 test_server_.host_port_pair().ToString(), &network_delegate);
3084
3085 {
3086 GURL original_url(test_server_.GetURL("empty.html"));
3087 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context);
3088
3089 r.Start();
3090 base::RunLoop().Run();
3091
3092 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
3093 EXPECT_EQ(0, r.status().error());
3094 EXPECT_EQ(redirect_url, r.url());
3095 EXPECT_EQ(original_url, r.original_url());
3096 EXPECT_EQ(2U, r.url_chain().size());
3097 EXPECT_EQ(2, network_delegate.created_requests());
3098 EXPECT_EQ(0, network_delegate.destroyed_requests());
3099 }
3100 EXPECT_EQ(1, network_delegate.destroyed_requests());
3101 }
3102
3011 // Tests that the network delegate can synchronously complete OnAuthRequired 3103 // Tests that the network delegate can synchronously complete OnAuthRequired
3012 // by taking no action. This indicates that the NetworkDelegate does not want to 3104 // by taking no action. This indicates that the NetworkDelegate does not want to
3013 // handle the challenge, and is passing the buck along to the 3105 // handle the challenge, and is passing the buck along to the
3014 // URLRequest::Delegate. 3106 // URLRequest::Delegate.
3015 TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncNoAction) { 3107 TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncNoAction) {
3016 ASSERT_TRUE(test_server_.Start()); 3108 ASSERT_TRUE(test_server_.Start());
3017 3109
3018 TestDelegate d; 3110 TestDelegate d;
3019 BlockingNetworkDelegate network_delegate( 3111 BlockingNetworkDelegate network_delegate(
3020 BlockingNetworkDelegate::SYNCHRONOUS); 3112 BlockingNetworkDelegate::SYNCHRONOUS);
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
3913 const CompletionCallback& callback, 4005 const CompletionCallback& callback,
3914 HttpRequestHeaders* headers) OVERRIDE { 4006 HttpRequestHeaders* headers) OVERRIDE {
3915 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers); 4007 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers);
3916 return RunCallbackAsynchronously(request, callback); 4008 return RunCallbackAsynchronously(request, callback);
3917 } 4009 }
3918 4010
3919 virtual int OnHeadersReceived( 4011 virtual int OnHeadersReceived(
3920 URLRequest* request, 4012 URLRequest* request,
3921 const CompletionCallback& callback, 4013 const CompletionCallback& callback,
3922 const HttpResponseHeaders* original_response_headers, 4014 const HttpResponseHeaders* original_response_headers,
3923 scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE { 4015 scoped_refptr<HttpResponseHeaders>* override_response_headers,
3924 TestNetworkDelegate::OnHeadersReceived(request, callback, 4016 GURL* allowed_unsafe_redirect_url) OVERRIDE {
4017 TestNetworkDelegate::OnHeadersReceived(request,
4018 callback,
3925 original_response_headers, 4019 original_response_headers,
3926 override_response_headers); 4020 override_response_headers,
4021 allowed_unsafe_redirect_url);
3927 return RunCallbackAsynchronously(request, callback); 4022 return RunCallbackAsynchronously(request, callback);
3928 } 4023 }
3929 4024
3930 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( 4025 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired(
3931 URLRequest* request, 4026 URLRequest* request,
3932 const AuthChallengeInfo& auth_info, 4027 const AuthChallengeInfo& auth_info,
3933 const AuthCallback& callback, 4028 const AuthCallback& callback,
3934 AuthCredentials* credentials) OVERRIDE { 4029 AuthCredentials* credentials) OVERRIDE {
3935 AsyncDelegateLogger::Run( 4030 AsyncDelegateLogger::Run(
3936 request, 4031 request,
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
5228 req.Start(); 5323 req.Start();
5229 base::RunLoop().Run(); 5324 base::RunLoop().Run();
5230 5325
5231 EXPECT_EQ(URLRequestStatus::SUCCESS, req.status().status()); 5326 EXPECT_EQ(URLRequestStatus::SUCCESS, req.status().status());
5232 EXPECT_FALSE(req.was_cached()); 5327 EXPECT_FALSE(req.was_cached());
5233 EXPECT_EQ(0, d.received_redirect_count()); 5328 EXPECT_EQ(0, d.received_redirect_count());
5234 EXPECT_EQ(initial_url, req.url()); 5329 EXPECT_EQ(initial_url, req.url());
5235 } 5330 }
5236 } 5331 }
5237 5332
5333 //
5334 // Redirects from an URL with fragment to an unsafe URL without fragment should
5335 // be allowed.
5336 TEST_F(URLRequestTestHTTP, UnsafeRedirectWithReferenceFragment) {
5337 ASSERT_TRUE(test_server_.Start());
5338
5339 GURL original_url(test_server_.GetURL("original#fragment"));
5340 GURL unsafe_url("data:,url-marked-safe-and-used-in-redirect");
5341 GURL expected_url("data:,url-marked-safe-and-used-in-redirect#fragment");
5342
5343 default_network_delegate_.set_redirect_on_headers_received_url(unsafe_url);
5344 default_network_delegate_.set_allowed_unsafe_redirect_url(unsafe_url);
5345
5346 TestDelegate d;
5347 {
5348 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &default_context_);
5349
5350 r.Start();
5351 base::RunLoop().Run();
5352
5353 EXPECT_EQ(2U, r.url_chain().size());
5354 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
5355 EXPECT_EQ(0, r.status().error());
5356 EXPECT_EQ(original_url, r.original_url());
5357 EXPECT_EQ(expected_url, r.url());
5358 }
5359 }
5360
5361 // When a delegate has specified a safe redirect URL, but it does not match the
5362 // redirect target, then do not prevent the reference fragment from being added.
5363 TEST_F(URLRequestTestHTTP, RedirectWithReferenceFragment) {
5364 ASSERT_TRUE(test_server_.Start());
5365
5366 GURL original_url(test_server_.GetURL("original#expected-fragment"));
5367 GURL unsafe_url("data:text/html,this-url-does-not-match-redirect-url");
5368 GURL redirect_url(test_server_.GetURL("target"));
5369 GURL expected_redirect_url(test_server_.GetURL("target#expected-fragment"));
5370
5371 default_network_delegate_.set_redirect_on_headers_received_url(redirect_url);
5372 default_network_delegate_.set_allowed_unsafe_redirect_url(unsafe_url);
5373
5374 TestDelegate d;
5375 {
5376 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &default_context_);
5377
5378 r.Start();
5379 base::RunLoop().Run();
5380
5381 EXPECT_EQ(2U, r.url_chain().size());
5382 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
5383 EXPECT_EQ(0, r.status().error());
5384 EXPECT_EQ(original_url, r.original_url());
5385 EXPECT_EQ(expected_redirect_url, r.url());
5386 }
5387 }
5388
5238 TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) { 5389 TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) {
5239 ASSERT_TRUE(test_server_.Start()); 5390 ASSERT_TRUE(test_server_.Start());
5240 5391
5241 TestDelegate d; 5392 TestDelegate d;
5242 URLRequest req(test_server_.GetURL("echoheader?Referer"), 5393 URLRequest req(test_server_.GetURL("echoheader?Referer"),
5243 DEFAULT_PRIORITY, 5394 DEFAULT_PRIORITY,
5244 &d, 5395 &d,
5245 &default_context_); 5396 &default_context_);
5246 req.SetReferrer("http://user:pass@foo.com/"); 5397 req.SetReferrer("http://user:pass@foo.com/");
5247 req.Start(); 5398 req.Start();
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after
7739 7890
7740 EXPECT_FALSE(r.is_pending()); 7891 EXPECT_FALSE(r.is_pending());
7741 EXPECT_EQ(1, d->response_started_count()); 7892 EXPECT_EQ(1, d->response_started_count());
7742 EXPECT_FALSE(d->received_data_before_response()); 7893 EXPECT_FALSE(d->received_data_before_response());
7743 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 7894 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
7744 } 7895 }
7745 } 7896 }
7746 #endif // !defined(DISABLE_FTP_SUPPORT) 7897 #endif // !defined(DISABLE_FTP_SUPPORT)
7747 7898
7748 } // namespace net 7899 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698