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 "net/url_request/url_request_unittest.h" | 5 #include "net/url_request/url_request_unittest.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 did_simulate_error_main_(false), | 1872 did_simulate_error_main_(false), |
1873 did_intercept_redirect_(false), did_cancel_redirect_(false), | 1873 did_intercept_redirect_(false), did_cancel_redirect_(false), |
1874 did_intercept_final_(false), did_cancel_final_(false) { | 1874 did_intercept_final_(false), did_cancel_final_(false) { |
1875 net::URLRequest::RegisterRequestInterceptor(this); | 1875 net::URLRequest::RegisterRequestInterceptor(this); |
1876 } | 1876 } |
1877 | 1877 |
1878 ~TestInterceptor() { | 1878 ~TestInterceptor() { |
1879 net::URLRequest::UnregisterRequestInterceptor(this); | 1879 net::URLRequest::UnregisterRequestInterceptor(this); |
1880 } | 1880 } |
1881 | 1881 |
1882 virtual URLRequestJob* MaybeIntercept(net::URLRequest* request) { | 1882 virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request) { |
1883 if (restart_main_request_) { | 1883 if (restart_main_request_) { |
1884 restart_main_request_ = false; | 1884 restart_main_request_ = false; |
1885 did_restart_main_ = true; | 1885 did_restart_main_ = true; |
1886 return new RestartTestJob(request); | 1886 return new RestartTestJob(request); |
1887 } | 1887 } |
1888 if (cancel_main_request_) { | 1888 if (cancel_main_request_) { |
1889 cancel_main_request_ = false; | 1889 cancel_main_request_ = false; |
1890 did_cancel_main_ = true; | 1890 did_cancel_main_ = true; |
1891 return new CancelTestJob(request); | 1891 return new CancelTestJob(request); |
1892 } | 1892 } |
(...skipping 11 matching lines...) Expand all Loading... |
1904 if (!intercept_main_request_) | 1904 if (!intercept_main_request_) |
1905 return NULL; | 1905 return NULL; |
1906 intercept_main_request_ = false; | 1906 intercept_main_request_ = false; |
1907 did_intercept_main_ = true; | 1907 did_intercept_main_ = true; |
1908 return new URLRequestTestJob(request, | 1908 return new URLRequestTestJob(request, |
1909 main_headers_, | 1909 main_headers_, |
1910 main_data_, | 1910 main_data_, |
1911 true); | 1911 true); |
1912 } | 1912 } |
1913 | 1913 |
1914 virtual URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request, | 1914 virtual net::URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request, |
1915 const GURL& location) { | 1915 const GURL& location) { |
1916 if (cancel_redirect_request_) { | 1916 if (cancel_redirect_request_) { |
1917 cancel_redirect_request_ = false; | 1917 cancel_redirect_request_ = false; |
1918 did_cancel_redirect_ = true; | 1918 did_cancel_redirect_ = true; |
1919 return new CancelTestJob(request); | 1919 return new CancelTestJob(request); |
1920 } | 1920 } |
1921 if (!intercept_redirect_) | 1921 if (!intercept_redirect_) |
1922 return NULL; | 1922 return NULL; |
1923 intercept_redirect_ = false; | 1923 intercept_redirect_ = false; |
1924 did_intercept_redirect_ = true; | 1924 did_intercept_redirect_ = true; |
1925 return new URLRequestTestJob(request, | 1925 return new URLRequestTestJob(request, |
1926 redirect_headers_, | 1926 redirect_headers_, |
1927 redirect_data_, | 1927 redirect_data_, |
1928 true); | 1928 true); |
1929 } | 1929 } |
1930 | 1930 |
1931 virtual URLRequestJob* MaybeInterceptResponse(net::URLRequest* request) { | 1931 virtual net::URLRequestJob* MaybeInterceptResponse(net::URLRequest* request) { |
1932 if (cancel_final_request_) { | 1932 if (cancel_final_request_) { |
1933 cancel_final_request_ = false; | 1933 cancel_final_request_ = false; |
1934 did_cancel_final_ = true; | 1934 did_cancel_final_ = true; |
1935 return new CancelTestJob(request); | 1935 return new CancelTestJob(request); |
1936 } | 1936 } |
1937 if (!intercept_final_response_) | 1937 if (!intercept_final_response_) |
1938 return NULL; | 1938 return NULL; |
1939 intercept_final_response_ = false; | 1939 intercept_final_response_ = false; |
1940 did_intercept_final_ = true; | 1940 did_intercept_final_ = true; |
1941 return new URLRequestTestJob(request, | 1941 return new URLRequestTestJob(request, |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 TestURLRequest | 2635 TestURLRequest |
2636 req(test_server_.GetURL("echoheaderoverride?Accept-Charset"), &d); | 2636 req(test_server_.GetURL("echoheaderoverride?Accept-Charset"), &d); |
2637 req.set_context(new TestURLRequestContext()); | 2637 req.set_context(new TestURLRequestContext()); |
2638 net::HttpRequestHeaders headers; | 2638 net::HttpRequestHeaders headers; |
2639 headers.SetHeader(net::HttpRequestHeaders::kAcceptCharset, "koi-8r"); | 2639 headers.SetHeader(net::HttpRequestHeaders::kAcceptCharset, "koi-8r"); |
2640 req.SetExtraRequestHeaders(headers); | 2640 req.SetExtraRequestHeaders(headers); |
2641 req.Start(); | 2641 req.Start(); |
2642 MessageLoop::current()->Run(); | 2642 MessageLoop::current()->Run(); |
2643 EXPECT_EQ(std::string("koi-8r"), d.data_received()); | 2643 EXPECT_EQ(std::string("koi-8r"), d.data_received()); |
2644 } | 2644 } |
OLD | NEW |