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

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: Rebased Created 6 years, 10 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
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 const CompletionCallback& callback, 359 const CompletionCallback& callback,
360 GURL* new_url) OVERRIDE; 360 GURL* new_url) OVERRIDE;
361 361
362 virtual int OnBeforeSendHeaders(URLRequest* request, 362 virtual int OnBeforeSendHeaders(URLRequest* request,
363 const CompletionCallback& callback, 363 const CompletionCallback& callback,
364 HttpRequestHeaders* headers) OVERRIDE; 364 HttpRequestHeaders* headers) OVERRIDE;
365 365
366 virtual int OnHeadersReceived( 366 virtual int OnHeadersReceived(
367 URLRequest* request, 367 URLRequest* request,
368 const CompletionCallback& callback, 368 const CompletionCallback& callback,
369 GURL* new_url,
369 const HttpResponseHeaders* original_response_headers, 370 const HttpResponseHeaders* original_response_headers,
370 scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE; 371 scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE;
371 372
372 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( 373 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired(
373 URLRequest* request, 374 URLRequest* request,
374 const AuthChallengeInfo& auth_info, 375 const AuthChallengeInfo& auth_info,
375 const AuthCallback& callback, 376 const AuthCallback& callback,
376 AuthCredentials* credentials) OVERRIDE; 377 AuthCredentials* credentials) OVERRIDE;
377 378
378 // Resets the callbacks and |stage_blocked_for_callback_|. 379 // Resets the callbacks and |stage_blocked_for_callback_|.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 472
472 int BlockingNetworkDelegate::OnBeforeSendHeaders( 473 int BlockingNetworkDelegate::OnBeforeSendHeaders(
473 URLRequest* request, 474 URLRequest* request,
474 const CompletionCallback& callback, 475 const CompletionCallback& callback,
475 HttpRequestHeaders* headers) { 476 HttpRequestHeaders* headers) {
476 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers); 477 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers);
477 478
478 return MaybeBlockStage(ON_BEFORE_SEND_HEADERS, callback); 479 return MaybeBlockStage(ON_BEFORE_SEND_HEADERS, callback);
479 } 480 }
480 481
481 int BlockingNetworkDelegate::OnHeadersReceived( 482 int BlockingNetworkDelegate::OnHeadersReceived(
battre 2014/02/12 11:54:48 I think this should have similar logic for redirec
482 URLRequest* request, 483 URLRequest* request,
483 const CompletionCallback& callback, 484 const CompletionCallback& callback,
485 GURL* new_url,
484 const HttpResponseHeaders* original_response_headers, 486 const HttpResponseHeaders* original_response_headers,
485 scoped_refptr<HttpResponseHeaders>* override_response_headers) { 487 scoped_refptr<HttpResponseHeaders>* override_response_headers) {
486 TestNetworkDelegate::OnHeadersReceived( 488 TestNetworkDelegate::OnHeadersReceived(
487 request, callback, original_response_headers, 489 request, callback, new_url, original_response_headers,
488 override_response_headers); 490 override_response_headers);
489 491
490 return MaybeBlockStage(ON_HEADERS_RECEIVED, callback); 492 return MaybeBlockStage(ON_HEADERS_RECEIVED, callback);
491 } 493 }
492 494
493 NetworkDelegate::AuthRequiredResponse BlockingNetworkDelegate::OnAuthRequired( 495 NetworkDelegate::AuthRequiredResponse BlockingNetworkDelegate::OnAuthRequired(
494 URLRequest* request, 496 URLRequest* request,
495 const AuthChallengeInfo& auth_info, 497 const AuthChallengeInfo& auth_info,
496 const AuthCallback& callback, 498 const AuthCallback& callback,
497 AuthCredentials* credentials) { 499 AuthCredentials* credentials) {
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 class FixedDateNetworkDelegate : public TestNetworkDelegate { 2410 class FixedDateNetworkDelegate : public TestNetworkDelegate {
2409 public: 2411 public:
2410 explicit FixedDateNetworkDelegate(const std::string& fixed_date) 2412 explicit FixedDateNetworkDelegate(const std::string& fixed_date)
2411 : fixed_date_(fixed_date) {} 2413 : fixed_date_(fixed_date) {}
2412 virtual ~FixedDateNetworkDelegate() {} 2414 virtual ~FixedDateNetworkDelegate() {}
2413 2415
2414 // net::NetworkDelegate implementation 2416 // net::NetworkDelegate implementation
2415 virtual int OnHeadersReceived( 2417 virtual int OnHeadersReceived(
2416 net::URLRequest* request, 2418 net::URLRequest* request,
2417 const net::CompletionCallback& callback, 2419 const net::CompletionCallback& callback,
2420 GURL* new_url,
2418 const net::HttpResponseHeaders* original_response_headers, 2421 const net::HttpResponseHeaders* original_response_headers,
2419 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) 2422 scoped_refptr<net::HttpResponseHeaders>* override_response_headers)
2420 OVERRIDE; 2423 OVERRIDE;
2421 2424
2422 private: 2425 private:
2423 std::string fixed_date_; 2426 std::string fixed_date_;
2424 2427
2425 DISALLOW_COPY_AND_ASSIGN(FixedDateNetworkDelegate); 2428 DISALLOW_COPY_AND_ASSIGN(FixedDateNetworkDelegate);
2426 }; 2429 };
2427 2430
2428 int FixedDateNetworkDelegate::OnHeadersReceived( 2431 int FixedDateNetworkDelegate::OnHeadersReceived(
2429 net::URLRequest* request, 2432 net::URLRequest* request,
2430 const net::CompletionCallback& callback, 2433 const net::CompletionCallback& callback,
2434 GURL* new_url,
2431 const net::HttpResponseHeaders* original_response_headers, 2435 const net::HttpResponseHeaders* original_response_headers,
2432 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) { 2436 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
2433 net::HttpResponseHeaders* new_response_headers = 2437 net::HttpResponseHeaders* new_response_headers =
2434 new net::HttpResponseHeaders(original_response_headers->raw_headers()); 2438 new net::HttpResponseHeaders(original_response_headers->raw_headers());
2435 2439
2436 new_response_headers->RemoveHeader("Date"); 2440 new_response_headers->RemoveHeader("Date");
2437 new_response_headers->AddHeader("Date: " + fixed_date_); 2441 new_response_headers->AddHeader("Date: " + fixed_date_);
2438 2442
2439 *override_response_headers = new_response_headers; 2443 *override_response_headers = new_response_headers;
2440 return TestNetworkDelegate::OnHeadersReceived(request, 2444 return TestNetworkDelegate::OnHeadersReceived(request,
2441 callback, 2445 callback,
2446 new_url,
2442 original_response_headers, 2447 original_response_headers,
2443 override_response_headers); 2448 override_response_headers);
2444 } 2449 }
2445 2450
2446 // Test that cookie expiration times are adjusted for server/client clock 2451 // Test that cookie expiration times are adjusted for server/client clock
2447 // skew and that we handle incorrect timezone specifier "UTC" in HTTP Date 2452 // skew and that we handle incorrect timezone specifier "UTC" in HTTP Date
2448 // headers by defaulting to GMT. (crbug.com/135131) 2453 // headers by defaulting to GMT. (crbug.com/135131)
2449 TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) { 2454 TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) {
2450 LocalHttpTestServer test_server; 2455 LocalHttpTestServer test_server;
2451 ASSERT_TRUE(test_server.Start()); 2456 ASSERT_TRUE(test_server.Start());
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 virtual int OnBeforeSendHeaders(URLRequest* request, 3916 virtual int OnBeforeSendHeaders(URLRequest* request,
3912 const CompletionCallback& callback, 3917 const CompletionCallback& callback,
3913 HttpRequestHeaders* headers) OVERRIDE { 3918 HttpRequestHeaders* headers) OVERRIDE {
3914 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers); 3919 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers);
3915 return RunCallbackAsynchronously(request, callback); 3920 return RunCallbackAsynchronously(request, callback);
3916 } 3921 }
3917 3922
3918 virtual int OnHeadersReceived( 3923 virtual int OnHeadersReceived(
3919 URLRequest* request, 3924 URLRequest* request,
3920 const CompletionCallback& callback, 3925 const CompletionCallback& callback,
3926 GURL* new_url,
3921 const HttpResponseHeaders* original_response_headers, 3927 const HttpResponseHeaders* original_response_headers,
3922 scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE { 3928 scoped_refptr<HttpResponseHeaders>* override_response_headers) OVERRIDE {
3923 TestNetworkDelegate::OnHeadersReceived(request, callback, 3929 TestNetworkDelegate::OnHeadersReceived(request, callback, new_url,
3924 original_response_headers, 3930 original_response_headers,
3925 override_response_headers); 3931 override_response_headers);
3926 return RunCallbackAsynchronously(request, callback); 3932 return RunCallbackAsynchronously(request, callback);
3927 } 3933 }
3928 3934
3929 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( 3935 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired(
3930 URLRequest* request, 3936 URLRequest* request,
3931 const AuthChallengeInfo& auth_info, 3937 const AuthChallengeInfo& auth_info,
3932 const AuthCallback& callback, 3938 const AuthCallback& callback,
3933 AuthCredentials* credentials) OVERRIDE { 3939 AuthCredentials* credentials) OVERRIDE {
(...skipping 3659 matching lines...) Expand 10 before | Expand all | Expand 10 after
7593 7599
7594 EXPECT_FALSE(r.is_pending()); 7600 EXPECT_FALSE(r.is_pending());
7595 EXPECT_EQ(1, d->response_started_count()); 7601 EXPECT_EQ(1, d->response_started_count());
7596 EXPECT_FALSE(d->received_data_before_response()); 7602 EXPECT_FALSE(d->received_data_before_response());
7597 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 7603 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
7598 } 7604 }
7599 } 7605 }
7600 #endif // !defined(DISABLE_FTP_SUPPORT) 7606 #endif // !defined(DISABLE_FTP_SUPPORT)
7601 7607
7602 } // namespace net 7608 } // namespace net
OLDNEW
« net/url_request/url_request_http_job.cc ('K') | « 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