OLD | NEW |
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 "net/url_request/url_request_test_util.h" | 5 #include "net/url_request/url_request_test_util.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 cookie_options_bit_mask_(0), | 167 cookie_options_bit_mask_(0), |
168 response_started_count_(0), | 168 response_started_count_(0), |
169 received_bytes_count_(0), | 169 received_bytes_count_(0), |
170 received_redirect_count_(0), | 170 received_redirect_count_(0), |
171 blocked_get_cookies_count_(0), | 171 blocked_get_cookies_count_(0), |
172 blocked_set_cookie_count_(0), | 172 blocked_set_cookie_count_(0), |
173 set_cookie_count_(0), | 173 set_cookie_count_(0), |
174 received_data_before_response_(false), | 174 received_data_before_response_(false), |
175 request_failed_(false), | 175 request_failed_(false), |
176 have_certificate_errors_(false), | 176 have_certificate_errors_(false), |
177 is_hsts_host_(false), | 177 certificate_errors_are_fatal_(false), |
178 auth_required_(false), | 178 auth_required_(false), |
179 buf_(new net::IOBuffer(kBufferSize)) { | 179 buf_(new net::IOBuffer(kBufferSize)) { |
180 } | 180 } |
181 | 181 |
182 TestDelegate::~TestDelegate() {} | 182 TestDelegate::~TestDelegate() {} |
183 | 183 |
184 void TestDelegate::OnReceivedRedirect(net::URLRequest* request, | 184 void TestDelegate::OnReceivedRedirect(net::URLRequest* request, |
185 const GURL& new_url, | 185 const GURL& new_url, |
186 bool* defer_redirect) { | 186 bool* defer_redirect) { |
187 received_redirect_count_++; | 187 received_redirect_count_++; |
(...skipping 10 matching lines...) Expand all Loading... |
198 auth_required_ = true; | 198 auth_required_ = true; |
199 if (!credentials_.Empty()) { | 199 if (!credentials_.Empty()) { |
200 request->SetAuth(credentials_); | 200 request->SetAuth(credentials_); |
201 } else { | 201 } else { |
202 request->CancelAuth(); | 202 request->CancelAuth(); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 void TestDelegate::OnSSLCertificateError(net::URLRequest* request, | 206 void TestDelegate::OnSSLCertificateError(net::URLRequest* request, |
207 const net::SSLInfo& ssl_info, | 207 const net::SSLInfo& ssl_info, |
208 bool is_hsts_host) { | 208 bool fatal) { |
209 // The caller can control whether it needs all SSL requests to go through, | 209 // The caller can control whether it needs all SSL requests to go through, |
210 // independent of any possible errors, or whether it wants SSL errors to | 210 // independent of any possible errors, or whether it wants SSL errors to |
211 // cancel the request. | 211 // cancel the request. |
212 have_certificate_errors_ = true; | 212 have_certificate_errors_ = true; |
213 is_hsts_host_ = is_hsts_host; | 213 certificate_errors_are_fatal_ = fatal; |
214 if (allow_certificate_errors_) | 214 if (allow_certificate_errors_) |
215 request->ContinueDespiteLastError(); | 215 request->ContinueDespiteLastError(); |
216 else | 216 else |
217 request->Cancel(); | 217 request->Cancel(); |
218 } | 218 } |
219 | 219 |
220 bool TestDelegate::CanGetCookies(const net::URLRequest* request, | 220 bool TestDelegate::CanGetCookies(const net::URLRequest* request, |
221 const net::CookieList& cookie_list) const { | 221 const net::CookieList& cookie_list) const { |
222 bool allow = true; | 222 bool allow = true; |
223 if (cookie_options_bit_mask_ & NO_GET_COOKIES) | 223 if (cookie_options_bit_mask_ & NO_GET_COOKIES) |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 event_order_[req_id] += "OnAuthRequired\n"; | 489 event_order_[req_id] += "OnAuthRequired\n"; |
490 EXPECT_TRUE(next_states_[req_id] & kStageAuthRequired) << | 490 EXPECT_TRUE(next_states_[req_id] & kStageAuthRequired) << |
491 event_order_[req_id]; | 491 event_order_[req_id]; |
492 next_states_[req_id] = kStageBeforeSendHeaders | | 492 next_states_[req_id] = kStageBeforeSendHeaders | |
493 kStageHeadersReceived | // Request canceled by delegate simulates empty | 493 kStageHeadersReceived | // Request canceled by delegate simulates empty |
494 // response. | 494 // response. |
495 kStageResponseStarted | // data: URLs do not trigger sending headers | 495 kStageResponseStarted | // data: URLs do not trigger sending headers |
496 kStageBeforeRedirect; // a delegate can trigger a redirection | 496 kStageBeforeRedirect; // a delegate can trigger a redirection |
497 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 497 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
498 } | 498 } |
OLD | NEW |