| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/fetch/Request.h" | 6 #include "modules/fetch/Request.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 r->headers()->fillWith(init.headersDictionary, exceptionState); | 172 r->headers()->fillWith(init.headersDictionary, exceptionState); |
| 173 } else { | 173 } else { |
| 174 ASSERT(headers); | 174 ASSERT(headers); |
| 175 r->headers()->fillWith(headers, exceptionState); | 175 r->headers()->fillWith(headers, exceptionState); |
| 176 } | 176 } |
| 177 if (exceptionState.hadException()) | 177 if (exceptionState.hadException()) |
| 178 return 0; | 178 return 0; |
| 179 | 179 |
| 180 // "21. If |init|'s body member is present, run these substeps:" | 180 // "21. If |init|'s body member is present, run these substeps:" |
| 181 if (init.bodyBlobHandle) { | 181 if (init.bodyBlobHandle) { |
| 182 // "1. Let |stream| and |Content-Type| be the result of extracting | 182 // "1. If request's method is `GET` or `HEAD`, throw a TypeError." |
| 183 // |init|'s body member." | 183 // "2. Let |stream| and |Content-Type| be the result of extracting |
| 184 // "2. Set |r|'s request's body to |stream|." | 184 // |init|'s body member." |
| 185 // "3.If |Content-Type| is non-null and |r|'s request's header list | 185 // "3. Set |r|'s request's body to |stream|." |
| 186 // "4. If |Content-Type| is non-null and |r|'s request's header list |
| 186 // contains no header named `Content-Type`, append | 187 // contains no header named `Content-Type`, append |
| 187 // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any | 188 // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any |
| 188 // exception." | 189 // exception." |
| 190 if (request->method() == "GET" || request->method() == "HEAD") { |
| 191 exceptionState.throwTypeError("Request with GET/HEAD method cannot h
ave body."); |
| 192 return 0; |
| 193 } |
| 189 r->setBodyBlobHandle(init.bodyBlobHandle); | 194 r->setBodyBlobHandle(init.bodyBlobHandle); |
| 190 if (!init.bodyBlobHandle->type().isEmpty() && !r->headers()->has("Conten
t-Type", exceptionState)) { | 195 if (!init.bodyBlobHandle->type().isEmpty() && !r->headers()->has("Conten
t-Type", exceptionState)) { |
| 191 r->headers()->append("Content-Type", init.bodyBlobHandle->type(), ex
ceptionState); | 196 r->headers()->append("Content-Type", init.bodyBlobHandle->type(), ex
ceptionState); |
| 192 } | 197 } |
| 193 if (exceptionState.hadException()) | 198 if (exceptionState.hadException()) |
| 194 return 0; | 199 return 0; |
| 195 } | 200 } |
| 196 // "22. Set |r|'s MIME type to the result of extracting a MIME type from | 201 // "22. Set |r|'s MIME type to the result of extracting a MIME type from |
| 197 // |r|'s request's header list." | 202 // |r|'s request's header list." |
| 198 // FIXME: We don't have MIME type in Request object yet. | 203 // FIXME: We don't have MIME type in Request object yet. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } | 400 } |
| 396 | 401 |
| 397 void Request::trace(Visitor* visitor) | 402 void Request::trace(Visitor* visitor) |
| 398 { | 403 { |
| 399 Body::trace(visitor); | 404 Body::trace(visitor); |
| 400 visitor->trace(m_request); | 405 visitor->trace(m_request); |
| 401 visitor->trace(m_headers); | 406 visitor->trace(m_headers); |
| 402 } | 407 } |
| 403 | 408 |
| 404 } // namespace blink | 409 } // namespace blink |
| OLD | NEW |