| OLD | NEW |
| 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 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 GURL redirect_url(test_server_.GetURL("simple.html")); | 2942 GURL redirect_url(test_server_.GetURL("simple.html")); |
| 2943 network_delegate.set_redirect_url(redirect_url); | 2943 network_delegate.set_redirect_url(redirect_url); |
| 2944 | 2944 |
| 2945 TestURLRequestContextWithProxy context( | 2945 TestURLRequestContextWithProxy context( |
| 2946 test_server_.host_port_pair().ToString(), &network_delegate); | 2946 test_server_.host_port_pair().ToString(), &network_delegate); |
| 2947 | 2947 |
| 2948 { | 2948 { |
| 2949 GURL original_url(test_server_.GetURL("empty.html")); | 2949 GURL original_url(test_server_.GetURL("empty.html")); |
| 2950 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context); | 2950 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context); |
| 2951 | 2951 |
| 2952 // Quit after hitting the redirect, so can check the headers. |
| 2953 d.set_quit_on_redirect(true); |
| 2952 r.Start(); | 2954 r.Start(); |
| 2953 base::RunLoop().Run(); | 2955 base::RunLoop().Run(); |
| 2954 | 2956 |
| 2957 // Check headers from URLRequestJob. |
| 2958 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 2959 EXPECT_EQ(307, r.GetResponseCode()); |
| 2960 EXPECT_EQ(307, r.response_headers()->response_code()); |
| 2961 std::string location; |
| 2962 ASSERT_TRUE(r.response_headers()->EnumerateHeader(NULL, "Location", |
| 2963 &location)); |
| 2964 EXPECT_EQ(redirect_url, GURL(location)); |
| 2965 |
| 2966 // Let the request finish. |
| 2967 r.FollowDeferredRedirect(); |
| 2968 base::RunLoop().Run(); |
| 2955 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); | 2969 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 2956 EXPECT_TRUE(r.proxy_server().Equals(test_server_.host_port_pair())); | 2970 EXPECT_TRUE(r.proxy_server().Equals(test_server_.host_port_pair())); |
| 2957 EXPECT_EQ( | 2971 EXPECT_EQ( |
| 2958 1, network_delegate.observed_before_proxy_headers_sent_callbacks()); | 2972 1, network_delegate.observed_before_proxy_headers_sent_callbacks()); |
| 2959 EXPECT_TRUE( | 2973 EXPECT_TRUE( |
| 2960 network_delegate.last_observed_proxy().Equals( | 2974 network_delegate.last_observed_proxy().Equals( |
| 2961 test_server_.host_port_pair())); | 2975 test_server_.host_port_pair())); |
| 2962 | 2976 |
| 2963 EXPECT_EQ(0, r.status().error()); | 2977 EXPECT_EQ(0, r.status().error()); |
| 2964 EXPECT_EQ(redirect_url, r.url()); | 2978 EXPECT_EQ(redirect_url, r.url()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2981 GURL redirect_url(test_server_.GetURL("simple.html")); | 2995 GURL redirect_url(test_server_.GetURL("simple.html")); |
| 2982 network_delegate.set_redirect_url(redirect_url); | 2996 network_delegate.set_redirect_url(redirect_url); |
| 2983 | 2997 |
| 2984 TestURLRequestContextWithProxy context( | 2998 TestURLRequestContextWithProxy context( |
| 2985 test_server_.host_port_pair().ToString(), &network_delegate); | 2999 test_server_.host_port_pair().ToString(), &network_delegate); |
| 2986 | 3000 |
| 2987 { | 3001 { |
| 2988 GURL original_url(test_server_.GetURL("empty.html")); | 3002 GURL original_url(test_server_.GetURL("empty.html")); |
| 2989 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context); | 3003 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context); |
| 2990 | 3004 |
| 3005 // Quit after hitting the redirect, so can check the headers. |
| 3006 d.set_quit_on_redirect(true); |
| 2991 r.Start(); | 3007 r.Start(); |
| 2992 base::RunLoop().Run(); | 3008 base::RunLoop().Run(); |
| 2993 | 3009 |
| 3010 // Check headers from URLRequestJob. |
| 3011 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 3012 EXPECT_EQ(307, r.GetResponseCode()); |
| 3013 EXPECT_EQ(307, r.response_headers()->response_code()); |
| 3014 std::string location; |
| 3015 ASSERT_TRUE(r.response_headers()->EnumerateHeader(NULL, "Location", |
| 3016 &location)); |
| 3017 EXPECT_EQ(redirect_url, GURL(location)); |
| 3018 |
| 3019 // Let the request finish. |
| 3020 r.FollowDeferredRedirect(); |
| 3021 base::RunLoop().Run(); |
| 3022 |
| 2994 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); | 3023 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 2995 EXPECT_TRUE(r.proxy_server().Equals(test_server_.host_port_pair())); | 3024 EXPECT_TRUE(r.proxy_server().Equals(test_server_.host_port_pair())); |
| 2996 EXPECT_EQ( | 3025 EXPECT_EQ( |
| 2997 1, network_delegate.observed_before_proxy_headers_sent_callbacks()); | 3026 1, network_delegate.observed_before_proxy_headers_sent_callbacks()); |
| 2998 EXPECT_TRUE( | 3027 EXPECT_TRUE( |
| 2999 network_delegate.last_observed_proxy().Equals( | 3028 network_delegate.last_observed_proxy().Equals( |
| 3000 test_server_.host_port_pair())); | 3029 test_server_.host_port_pair())); |
| 3001 EXPECT_EQ(0, r.status().error()); | 3030 EXPECT_EQ(0, r.status().error()); |
| 3002 EXPECT_EQ(redirect_url, r.url()); | 3031 EXPECT_EQ(redirect_url, r.url()); |
| 3003 EXPECT_EQ(original_url, r.original_url()); | 3032 EXPECT_EQ(original_url, r.original_url()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3027 | 3056 |
| 3028 { | 3057 { |
| 3029 GURL original_url(test_server_.GetURL("empty.html")); | 3058 GURL original_url(test_server_.GetURL("empty.html")); |
| 3030 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context); | 3059 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context); |
| 3031 r.set_method("POST"); | 3060 r.set_method("POST"); |
| 3032 r.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); | 3061 r.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); |
| 3033 HttpRequestHeaders headers; | 3062 HttpRequestHeaders headers; |
| 3034 headers.SetHeader(HttpRequestHeaders::kContentLength, | 3063 headers.SetHeader(HttpRequestHeaders::kContentLength, |
| 3035 base::UintToString(arraysize(kData) - 1)); | 3064 base::UintToString(arraysize(kData) - 1)); |
| 3036 r.SetExtraRequestHeaders(headers); | 3065 r.SetExtraRequestHeaders(headers); |
| 3066 |
| 3067 // Quit after hitting the redirect, so can check the headers. |
| 3068 d.set_quit_on_redirect(true); |
| 3037 r.Start(); | 3069 r.Start(); |
| 3038 base::RunLoop().Run(); | 3070 base::RunLoop().Run(); |
| 3039 | 3071 |
| 3072 // Check headers from URLRequestJob. |
| 3073 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 3074 EXPECT_EQ(307, r.GetResponseCode()); |
| 3075 EXPECT_EQ(307, r.response_headers()->response_code()); |
| 3076 std::string location; |
| 3077 ASSERT_TRUE(r.response_headers()->EnumerateHeader(NULL, "Location", |
| 3078 &location)); |
| 3079 EXPECT_EQ(redirect_url, GURL(location)); |
| 3080 |
| 3081 // Let the request finish. |
| 3082 r.FollowDeferredRedirect(); |
| 3083 base::RunLoop().Run(); |
| 3084 |
| 3040 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); | 3085 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 3041 EXPECT_EQ(0, r.status().error()); | 3086 EXPECT_EQ(0, r.status().error()); |
| 3042 EXPECT_EQ(redirect_url, r.url()); | 3087 EXPECT_EQ(redirect_url, r.url()); |
| 3043 EXPECT_EQ(original_url, r.original_url()); | 3088 EXPECT_EQ(original_url, r.original_url()); |
| 3044 EXPECT_EQ(2U, r.url_chain().size()); | 3089 EXPECT_EQ(2U, r.url_chain().size()); |
| 3045 EXPECT_EQ(1, network_delegate.created_requests()); | 3090 EXPECT_EQ(1, network_delegate.created_requests()); |
| 3046 EXPECT_EQ(0, network_delegate.destroyed_requests()); | 3091 EXPECT_EQ(0, network_delegate.destroyed_requests()); |
| 3047 EXPECT_EQ("POST", r.method()); | 3092 EXPECT_EQ("POST", r.method()); |
| 3048 EXPECT_EQ(kData, d.data_received()); | 3093 EXPECT_EQ(kData, d.data_received()); |
| 3049 } | 3094 } |
| (...skipping 5049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8099 | 8144 |
| 8100 EXPECT_FALSE(r.is_pending()); | 8145 EXPECT_FALSE(r.is_pending()); |
| 8101 EXPECT_EQ(1, d->response_started_count()); | 8146 EXPECT_EQ(1, d->response_started_count()); |
| 8102 EXPECT_FALSE(d->received_data_before_response()); | 8147 EXPECT_FALSE(d->received_data_before_response()); |
| 8103 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 8148 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 8104 } | 8149 } |
| 8105 } | 8150 } |
| 8106 #endif // !defined(DISABLE_FTP_SUPPORT) | 8151 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 8107 | 8152 |
| 8108 } // namespace net | 8153 } // namespace net |
| OLD | NEW |