OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 return true; | 275 return true; |
276 } | 276 } |
277 | 277 |
278 bool passesPreflightStatusCheck(const ResourceResponse& response, | 278 bool passesPreflightStatusCheck(const ResourceResponse& response, |
279 String& errorDescription) { | 279 String& errorDescription) { |
280 // CORS preflight with 3XX is considered network error in | 280 // CORS preflight with 3XX is considered network error in |
281 // Fetch API Spec: https://fetch.spec.whatwg.org/#cors-preflight-fetch | 281 // Fetch API Spec: https://fetch.spec.whatwg.org/#cors-preflight-fetch |
282 // CORS Spec: http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0 | 282 // CORS Spec: http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0 |
283 // https://crbug.com/452394 | 283 // https://crbug.com/452394 |
284 if (response.httpStatusCode() < 200 || response.httpStatusCode() >= 300) { | 284 int statusCode = response.httpStatusCode(); |
| 285 if (!FetchUtils::isOkStatus(statusCode)) { |
285 errorDescription = "Response for preflight has invalid HTTP status code " + | 286 errorDescription = "Response for preflight has invalid HTTP status code " + |
286 String::number(response.httpStatusCode()); | 287 String::number(statusCode); |
287 return false; | 288 return false; |
288 } | 289 } |
289 | 290 |
290 return true; | 291 return true; |
291 } | 292 } |
292 | 293 |
293 bool passesExternalPreflightCheck(const ResourceResponse& response, | 294 bool passesExternalPreflightCheck(const ResourceResponse& response, |
294 String& errorDescription) { | 295 String& errorDescription) { |
295 AtomicString result = | 296 AtomicString result = |
296 response.httpHeaderField(HTTPNames::Access_Control_Allow_External); | 297 response.httpHeaderField(HTTPNames::Access_Control_Allow_External); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // | 428 // |
428 // This is equivalent to the step 2 in | 429 // This is equivalent to the step 2 in |
429 // https://fetch.spec.whatwg.org/#http-network-or-cache-fetch | 430 // https://fetch.spec.whatwg.org/#http-network-or-cache-fetch |
430 if (options.credentialsRequested == ClientDidNotRequestCredentials) | 431 if (options.credentialsRequested == ClientDidNotRequestCredentials) |
431 options.allowCredentials = DoNotAllowStoredCredentials; | 432 options.allowCredentials = DoNotAllowStoredCredentials; |
432 } | 433 } |
433 return true; | 434 return true; |
434 } | 435 } |
435 | 436 |
436 } // namespace blink | 437 } // namespace blink |
OLD | NEW |