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 23 matching lines...) Expand all Loading... | |
34 DOMWrapperWorld& world = scriptState->world(); | 34 DOMWrapperWorld& world = scriptState->world(); |
35 if (world.isIsolatedWorld()) | 35 if (world.isIsolatedWorld()) |
36 request->setOrigin(world.isolatedWorldSecurityOrigin()); | 36 request->setOrigin(world.isolatedWorldSecurityOrigin()); |
37 else | 37 else |
38 request->setOrigin(scriptState->executionContext()->securityOrigin()); | 38 request->setOrigin(scriptState->executionContext()->securityOrigin()); |
39 // FIXME: Set ForceOriginHeaderFlag. | 39 // FIXME: Set ForceOriginHeaderFlag. |
40 request->setSameOriginDataURLFlag(true); | 40 request->setSameOriginDataURLFlag(true); |
41 request->mutableReferrer()->setClient(); | 41 request->mutableReferrer()->setClient(); |
42 request->setMode(original->mode()); | 42 request->setMode(original->mode()); |
43 request->setCredentials(original->credentials()); | 43 request->setCredentials(original->credentials()); |
44 request->setRedirect(original->redirect()); | |
44 // FIXME: Set cache mode. | 45 // FIXME: Set cache mode. |
45 // TODO(yhirano): Set redirect mode. | 46 // TODO(yhirano): Set redirect mode. |
46 return request; | 47 return request; |
47 } | 48 } |
48 | 49 |
49 Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req uest* inputRequest, const String& inputString, const RequestInit& init, Exceptio nState& exceptionState) | 50 Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req uest* inputRequest, const String& inputString, const RequestInit& init, Exceptio nState& exceptionState) |
50 { | 51 { |
51 // "1. Let |temporaryBody| be null." | 52 // "1. Let |temporaryBody| be null." |
52 BodyStreamBuffer* temporaryBody = nullptr; | 53 BodyStreamBuffer* temporaryBody = nullptr; |
53 | 54 |
(...skipping 13 matching lines...) Expand all Loading... | |
67 // "2. Set |temporaryBody| to |input|'s body." | 68 // "2. Set |temporaryBody| to |input|'s body." |
68 if (inputRequest->bodyUsed()) { | 69 if (inputRequest->bodyUsed()) { |
69 exceptionState.throwTypeError("Cannot construct a Request with a Req uest object that has already been used."); | 70 exceptionState.throwTypeError("Cannot construct a Request with a Req uest object that has already been used."); |
70 return nullptr; | 71 return nullptr; |
71 } | 72 } |
72 temporaryBody = inputRequest->bodyBuffer(); | 73 temporaryBody = inputRequest->bodyBuffer(); |
73 } | 74 } |
74 | 75 |
75 // "3. Let |request| be |input|'s request, if |input| is a Request object, | 76 // "3. Let |request| be |input|'s request, if |input| is a Request object, |
76 // and a new request otherwise." | 77 // and a new request otherwise." |
77 // "4. Set |request| to a new request whose url is |request|'s url, method | 78 // TODO(yhirano): |
yhirano
2015/08/07 14:22:02
Please wrap the comment in 80 cols.
horo
2015/08/07 15:39:54
Done.
| |
78 // is |request|'s method, header list is a copy of |request|'s header list, | 79 // "4. Let origin be entry settings object's origin." |
79 // unsafe request flag is set, client is entry settings object, origin is | 80 // "5. Let window be client." |
80 // entry settings object's origin, force Origin header flag is set, | 81 // "6. If request's window is an environment settings object and its origi n is same origin with origin, set window to request's window." |
81 // same-origin data URL flag is set, context is the empty string, mode is | 82 // "7. If init's window member is present and it is not null, throw a Type Error." |
82 // |request|'s mode, credentials mode is |request|'s credentials mode, | 83 // "8. If init's window member is present, set window to no-window." |
83 // cache mode is |request|'s cache mode, and redirect mode is request's | 84 // "9. Set |request| to a new request whose url is |request|'s current url, |
84 // redirect mode." | 85 // method is |request|'s method, header list is a copy of |request|'s header |
86 // list, unsafe-request flag is set, client is entry settings object, window | |
87 // is window, origin is origin, force-Origin-header flag is set, same-origin | |
88 // data-URL flag is set, referrer is request's referrer, referrer policy is | |
89 // |request|'s referrer policy, context is the empty string, mode is | |
90 // |request|'s mode, credentials mode is |request|'s credentials mode, cache | |
91 // mode is |request|'s cache mode, redirect mode is |request|'s redirect | |
92 // mode, and integrity metadata is |request|'s integrity metadata." | |
85 FetchRequestData* request = createCopyOfFetchRequestDataForFetch(scriptState , inputRequest ? inputRequest->request() : FetchRequestData::create()); | 93 FetchRequestData* request = createCopyOfFetchRequestDataForFetch(scriptState , inputRequest ? inputRequest->request() : FetchRequestData::create()); |
86 | 94 |
87 // "5. Let |fallbackMode| be null." | 95 // "10. Let |fallbackMode| be null." |
88 // "6. Let |fallbackCredentials| be null." | 96 // "11. Let |fallbackCredentials| be null." |
89 // "7. Let |fallbackCache| be null." | 97 // "12. Let |baseURL| be entry settings object's API base URL." |
90 // "8. Let |fallbackRedirect| be null." | |
91 // We don't use fallback values. We set these flags directly in below. | 98 // We don't use fallback values. We set these flags directly in below. |
92 | 99 |
93 // "9. If |input| is a string, run these substeps:" | 100 // "13. If |input| is a string, run these substeps:" |
94 if (!inputRequest) { | 101 if (!inputRequest) { |
95 // "1. Let |parsedURL| be the result of parsing |input| with entry | 102 // "1. Let |parsedURL| be the result of parsing |input| with |baseURL|." |
96 // settings object's API base URL." | |
97 KURL parsedURL = scriptState->executionContext()->completeURL(inputStrin g); | 103 KURL parsedURL = scriptState->executionContext()->completeURL(inputStrin g); |
98 // "2. If |parsedURL| is failure, throw a TypeError." | 104 // "2. If |parsedURL| is failure, throw a TypeError." |
99 if (!parsedURL.isValid()) { | 105 if (!parsedURL.isValid()) { |
100 exceptionState.throwTypeError("Failed to parse URL from " + inputStr ing); | 106 exceptionState.throwTypeError("Failed to parse URL from " + inputStr ing); |
101 return nullptr; | 107 return nullptr; |
102 } | 108 } |
103 // TODO(yhirano): "3. If |parsedURL| includes credentials, throw a | 109 // TODO(yhirano): "3. If |parsedURL| includes credentials, throw a |
104 // TypeError." | 110 // TypeError." |
105 // "4. Set |request|'s url to |parsedURL|." | 111 // "4. Set |request|'s url to |parsedURL|." |
106 request->setURL(parsedURL); | 112 request->setURL(parsedURL); |
107 // "5. Set |fallbackMode| to CORS." | 113 // "5. Set |fallbackMode| to CORS." |
108 // "6. Set |fallbackCredentials| to omit." | 114 // "6. Set |fallbackCredentials| to omit." |
109 // "7. Set |fallbackCache| to default." | |
110 // "8. Set |fallbackRedirect| to follow." | |
111 // We don't use fallback values. We set these flags directly in below. | 115 // We don't use fallback values. We set these flags directly in below. |
112 } | 116 } |
113 | 117 |
114 // "10. Let |mode| be |init|'s mode member if it is present, and | 118 // TODO(yhirano): |
119 // "14. If any of |init|'s members are present, set |request|'s referrer | |
120 // to client, and |request|'s referrer policy to the empty string. | |
121 // 15. If |init|'s referrer member is present, run these substeps:... | |
122 // 16. If |init|'s referrerPolicy member is present, set |request|'s | |
123 // referrer policy to it." | |
124 | |
125 // "17. Let |mode| be |init|'s mode member if it is present, and | |
115 // |fallbackMode| otherwise." | 126 // |fallbackMode| otherwise." |
116 // "11. If |mode| is non-null, set |request|'s mode to |mode|." | 127 // "18. If |mode| is non-null, set |request|'s mode to |mode|." |
117 if (init.mode == "same-origin") { | 128 if (init.mode == "same-origin") { |
118 request->setMode(WebURLRequest::FetchRequestModeSameOrigin); | 129 request->setMode(WebURLRequest::FetchRequestModeSameOrigin); |
119 } else if (init.mode == "no-cors") { | 130 } else if (init.mode == "no-cors") { |
120 request->setMode(WebURLRequest::FetchRequestModeNoCORS); | 131 request->setMode(WebURLRequest::FetchRequestModeNoCORS); |
121 } else if (init.mode == "cors") { | 132 } else if (init.mode == "cors") { |
122 request->setMode(WebURLRequest::FetchRequestModeCORS); | 133 request->setMode(WebURLRequest::FetchRequestModeCORS); |
123 } else { | 134 } else { |
124 if (!inputRequest) | 135 if (!inputRequest) |
125 request->setMode(WebURLRequest::FetchRequestModeCORS); | 136 request->setMode(WebURLRequest::FetchRequestModeCORS); |
126 } | 137 } |
127 | 138 |
128 // "12. Let |credentials| be |init|'s credentials member if it is present, | 139 // "19. Let |credentials| be |init|'s credentials member if it is present, |
129 // and |fallbackCredentials| otherwise." | 140 // and |fallbackCredentials| otherwise." |
130 // "13. If |credentials| is non-null, set |request|'s credentials mode to | 141 // "20. If |credentials| is non-null, set |request|'s credentials mode to |
131 // |credentials|. | 142 // |credentials|. |
132 if (init.credentials == "omit") { | 143 if (init.credentials == "omit") { |
133 request->setCredentials(WebURLRequest::FetchCredentialsModeOmit); | 144 request->setCredentials(WebURLRequest::FetchCredentialsModeOmit); |
134 } else if (init.credentials == "same-origin") { | 145 } else if (init.credentials == "same-origin") { |
135 request->setCredentials(WebURLRequest::FetchCredentialsModeSameOrigin); | 146 request->setCredentials(WebURLRequest::FetchCredentialsModeSameOrigin); |
136 } else if (init.credentials == "include") { | 147 } else if (init.credentials == "include") { |
137 request->setCredentials(WebURLRequest::FetchCredentialsModeInclude); | 148 request->setCredentials(WebURLRequest::FetchCredentialsModeInclude); |
138 } else { | 149 } else { |
139 if (!inputRequest) | 150 if (!inputRequest) |
140 request->setCredentials(WebURLRequest::FetchCredentialsModeOmit); | 151 request->setCredentials(WebURLRequest::FetchCredentialsModeOmit); |
141 } | 152 } |
142 | 153 |
143 // FIXME: "14. Let |cache| be |init|'s cache member if it is present, and | 154 // FIXME: "21. If |init|'s cache member is present, set |request|'s cache |
falken
2015/08/07 07:39:12
these FIXME should now be TODO(horo) or TODO(yhira
horo
2015/08/07 09:19:33
Done.
| |
144 // |fallbackCache| otherwise." | 155 // mode to it." |
145 // FIXME: "15. If |cache| is non-null, set |request|'s cache mode to | |
146 // |cache|." | |
147 // TODO(yhirano): "16. If |init|'s redirect member is present and its is | |
148 // manual, throw a TypeError." | |
149 // TODO(yhirano): "17. Let |redirect| be |init|'s redirect member if it is | |
150 // present, and |fallbackRedirect| otherwise." | |
151 // TODO(yhirano): "18 If |redirect| is non-null, set |request|'s redirect | |
152 // mode to |redirect|." | |
153 // TODO(yhirano): "19 If |request|'s redirect mode is manual, set it to | |
154 // follow." | |
155 | 156 |
156 // "20. If |init|'s method member is present, let |method| be it and run | 157 // "22. If |init|'s redirect member is present, set |request|'s redirect |
158 // mode to it." | |
159 // TODO(horo): Support redirect flag when the chromium side patch land. | |
160 // if (init.redirect == "follw") { | |
falken
2015/08/07 07:39:12
nit: follw. i'd prefer to just not land commented
horo
2015/08/07 09:19:33
Done.
| |
161 // request->setRedirect(WebURLRequest::FetchRedirectModeFollow); | |
162 // } else if (init.redirect == "error") { | |
163 // request->setRedirect(WebURLRequest::FetchRedirectModeError); | |
164 // } else if (init.redirect == "manual") { | |
165 // request->setRedirect(WebURLRequest::FetchRedirectModeManual); | |
166 // } | |
167 | |
168 // FIXME: "23. If |init|'s integrity member is present, set |request|'s | |
169 // integrity metadata to it." | |
170 | |
171 // "24. If |init|'s method member is present, let |method| be it and run | |
157 // these substeps:" | 172 // these substeps:" |
158 if (!init.method.isNull()) { | 173 if (!init.method.isNull()) { |
159 // "1. If |method| is not a method or method is a forbidden method, | 174 // "1. If |method| is not a method or method is a forbidden method, |
160 // throw a TypeError." | 175 // throw a TypeError." |
161 if (!isValidHTTPToken(init.method)) { | 176 if (!isValidHTTPToken(init.method)) { |
162 exceptionState.throwTypeError("'" + init.method + "' is not a valid HTTP method."); | 177 exceptionState.throwTypeError("'" + init.method + "' is not a valid HTTP method."); |
163 return nullptr; | 178 return nullptr; |
164 } | 179 } |
165 if (FetchUtils::isForbiddenMethod(init.method)) { | 180 if (FetchUtils::isForbiddenMethod(init.method)) { |
166 exceptionState.throwTypeError("'" + init.method + "' HTTP method is unsupported."); | 181 exceptionState.throwTypeError("'" + init.method + "' HTTP method is unsupported."); |
167 return nullptr; | 182 return nullptr; |
168 } | 183 } |
169 // "2. Normalize |method|." | 184 // "2. Normalize |method|." |
170 // "3. Set |request|'s method to |method|." | 185 // "3. Set |request|'s method to |method|." |
171 request->setMethod(FetchUtils::normalizeMethod(AtomicString(init.method) )); | 186 request->setMethod(FetchUtils::normalizeMethod(AtomicString(init.method) )); |
172 } | 187 } |
173 // "21. Let |r| be a new Request object associated with |request| and a new | 188 // "25. Let |r| be a new Request object associated with |request| and a new |
174 // Headers object whose guard is request." | 189 // Headers object whose guard is request." |
175 Request* r = Request::create(scriptState->executionContext(), request); | 190 Request* r = Request::create(scriptState->executionContext(), request); |
176 // "22. Let |headers| be a copy of |r|'s Headers object." | 191 // "26. Let |headers| be a copy of |r|'s Headers object." |
177 // "23. If |init|'s headers member is present, set |headers| to |init|'s | 192 // "27. If |init|'s headers member is present, set |headers| to |init|'s |
178 // headers member." | 193 // headers member." |
179 // We don't create a copy of r's Headers object when init's headers member | 194 // We don't create a copy of r's Headers object when init's headers member |
180 // is present. | 195 // is present. |
181 Headers* headers = nullptr; | 196 Headers* headers = nullptr; |
182 if (!init.headers && init.headersDictionary.isUndefinedOrNull()) { | 197 if (!init.headers && init.headersDictionary.isUndefinedOrNull()) { |
183 headers = r->headers()->clone(); | 198 headers = r->headers()->clone(); |
184 } | 199 } |
185 // "24. Empty |r|'s request's header list." | 200 // "28. Empty |r|'s request's header list." |
186 r->m_request->headerList()->clearList(); | 201 r->m_request->headerList()->clearList(); |
187 // "25. If |r|'s request's mode is no CORS, run these substeps: | 202 // "29. If |r|'s request's mode is no CORS, run these substeps: |
188 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { | 203 if (r->request()->mode() == WebURLRequest::FetchRequestModeNoCORS) { |
189 // "1. If |r|'s request's method is not a simple method, throw a | 204 // "1. If |r|'s request's method is not a simple method, throw a |
190 // TypeError." | 205 // TypeError." |
191 if (!FetchUtils::isSimpleMethod(r->request()->method())) { | 206 if (!FetchUtils::isSimpleMethod(r->request()->method())) { |
192 exceptionState.throwTypeError("'" + r->request()->method() + "' is u nsupported in no-cors mode."); | 207 exceptionState.throwTypeError("'" + r->request()->method() + "' is u nsupported in no-cors mode."); |
193 return nullptr; | 208 return nullptr; |
194 } | 209 } |
195 // "Set |r|'s Headers object's guard to |request-no-CORS|. | 210 // "Set |r|'s Headers object's guard to |request-no-CORS|. |
196 r->headers()->setGuard(Headers::RequestNoCORSGuard); | 211 r->headers()->setGuard(Headers::RequestNoCORSGuard); |
197 } | 212 } |
198 // "26. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." | 213 // "30. Fill |r|'s Headers object with |headers|. Rethrow any exceptions." |
199 if (init.headers) { | 214 if (init.headers) { |
200 ASSERT(init.headersDictionary.isUndefinedOrNull()); | 215 ASSERT(init.headersDictionary.isUndefinedOrNull()); |
201 r->headers()->fillWith(init.headers.get(), exceptionState); | 216 r->headers()->fillWith(init.headers.get(), exceptionState); |
202 } else if (!init.headersDictionary.isUndefinedOrNull()) { | 217 } else if (!init.headersDictionary.isUndefinedOrNull()) { |
203 r->headers()->fillWith(init.headersDictionary, exceptionState); | 218 r->headers()->fillWith(init.headersDictionary, exceptionState); |
204 } else { | 219 } else { |
205 ASSERT(headers); | 220 ASSERT(headers); |
206 r->headers()->fillWith(headers, exceptionState); | 221 r->headers()->fillWith(headers, exceptionState); |
207 } | 222 } |
208 if (exceptionState.hadException()) | 223 if (exceptionState.hadException()) |
209 return nullptr; | 224 return nullptr; |
210 | 225 |
211 // "27. If either |init|'s body member is present or |temporaryBody| is | 226 // "31. If either |init|'s body member is present or |temporaryBody| is |
212 // non-null, and |request|'s method is `GET` or `HEAD`, throw a TypeError. | 227 // non-null, and |request|'s method is `GET` or `HEAD`, throw a TypeError. |
213 if (init.bodyBlobHandle || temporaryBody) { | 228 if (init.bodyBlobHandle || temporaryBody) { |
214 if (request->method() == "GET" || request->method() == "HEAD") { | 229 if (request->method() == "GET" || request->method() == "HEAD") { |
215 exceptionState.throwTypeError("Request with GET/HEAD method cannot h ave body."); | 230 exceptionState.throwTypeError("Request with GET/HEAD method cannot h ave body."); |
216 return nullptr; | 231 return nullptr; |
217 } | 232 } |
218 } | 233 } |
219 | 234 |
220 // "28. If |init|'s body member is present, run these substeps:" | 235 // "32. If |init|'s body member is present, run these substeps:" |
221 if (init.bodyBlobHandle) { | 236 if (init.bodyBlobHandle) { |
222 // "1. Let |stream| and |Content-Type| be the result of extracting | 237 // "1. Let |stream| and |Content-Type| be the result of extracting |
223 // |init|'s body member." | 238 // |init|'s body member." |
224 // "2. Set |temporaryBody| to |stream|. | 239 // "2. Set |temporaryBody| to |stream|. |
225 // "3. If |Content-Type| is non-null and |r|'s request's header list | 240 // "3. If |Content-Type| is non-null and |r|'s request's header list |
226 // contains no header named `Content-Type`, append | 241 // contains no header named `Content-Type`, append |
227 // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any | 242 // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any |
228 // exception." | 243 // exception." |
229 temporaryBody = new BodyStreamBuffer(FetchBlobDataConsumerHandle::create (scriptState->executionContext(), init.bodyBlobHandle)); | 244 temporaryBody = new BodyStreamBuffer(FetchBlobDataConsumerHandle::create (scriptState->executionContext(), init.bodyBlobHandle)); |
230 if (!init.bodyBlobHandle->type().isEmpty() && !r->headers()->has("Conten t-Type", exceptionState)) { | 245 if (!init.bodyBlobHandle->type().isEmpty() && !r->headers()->has("Conten t-Type", exceptionState)) { |
231 r->headers()->append("Content-Type", init.bodyBlobHandle->type(), ex ceptionState); | 246 r->headers()->append("Content-Type", init.bodyBlobHandle->type(), ex ceptionState); |
232 } | 247 } |
233 if (exceptionState.hadException()) | 248 if (exceptionState.hadException()) |
234 return nullptr; | 249 return nullptr; |
235 } | 250 } |
236 | 251 |
237 // "29. Set |r|'s body to |temporaryBody|. | 252 // "33. Set |r|'s body to |temporaryBody|. |
238 if (temporaryBody) | 253 if (temporaryBody) |
239 r->m_request->setBuffer(temporaryBody); | 254 r->m_request->setBuffer(temporaryBody); |
240 | 255 |
241 // "30. Set |r|'s MIME type to the result of extracting a MIME type from | 256 // "34. Set |r|'s MIME type to the result of extracting a MIME type from |
242 // |r|'s request's header list." | 257 // |r|'s request's header list." |
243 r->m_request->setMIMEType(r->m_request->headerList()->extractMIMEType()); | 258 r->m_request->setMIMEType(r->m_request->headerList()->extractMIMEType()); |
244 | 259 |
245 // "31. If |input| is a Request object and |input|'s body is non-null, run | 260 // "35. If |input| is a Request object and |input|'s body is non-null, run |
246 // these substeps:" | 261 // these substeps:" |
247 // We set bodyUsed even when the body is null in spite of the | 262 // We set bodyUsed even when the body is null in spite of the |
248 // spec. See https://github.com/whatwg/fetch/issues/61 for details. | 263 // spec. See https://github.com/whatwg/fetch/issues/61 for details. |
249 if (inputRequest) { | 264 if (inputRequest) { |
250 // "1. Set |input|'s body to null." | 265 // "1. Set |input|'s body to null." |
251 inputRequest->m_request->setBuffer(new BodyStreamBuffer); | 266 inputRequest->m_request->setBuffer(new BodyStreamBuffer); |
252 // "2. Set |input|'s used flag." | 267 // "2. Set |input|'s used flag." |
253 inputRequest->setBodyPassed(); | 268 inputRequest->setBodyPassed(); |
254 } | 269 } |
255 | 270 |
256 // "32. Return |r|." | 271 // "36. Return |r|." |
257 return r; | 272 return r; |
258 } | 273 } |
259 | 274 |
260 Request* Request::create(ScriptState* scriptState, const RequestInfo& input, con st Dictionary& init, ExceptionState& exceptionState) | 275 Request* Request::create(ScriptState* scriptState, const RequestInfo& input, con st Dictionary& init, ExceptionState& exceptionState) |
261 { | 276 { |
262 ASSERT(!input.isNull()); | 277 ASSERT(!input.isNull()); |
263 if (input.isUSVString()) | 278 if (input.isUSVString()) |
264 return create(scriptState, input.getAsUSVString(), init, exceptionState) ; | 279 return create(scriptState, input.getAsUSVString(), init, exceptionState) ; |
265 return create(scriptState, input.getAsRequest(), init, exceptionState); | 280 return create(scriptState, input.getAsRequest(), init, exceptionState); |
266 } | 281 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 return "omit"; | 461 return "omit"; |
447 case WebURLRequest::FetchCredentialsModeSameOrigin: | 462 case WebURLRequest::FetchCredentialsModeSameOrigin: |
448 return "same-origin"; | 463 return "same-origin"; |
449 case WebURLRequest::FetchCredentialsModeInclude: | 464 case WebURLRequest::FetchCredentialsModeInclude: |
450 return "include"; | 465 return "include"; |
451 } | 466 } |
452 ASSERT_NOT_REACHED(); | 467 ASSERT_NOT_REACHED(); |
453 return ""; | 468 return ""; |
454 } | 469 } |
455 | 470 |
471 String Request::redirect() const | |
472 { | |
473 // "The redirect attribute's getter must return request's redirect mode." | |
474 switch (m_request->redirect()) { | |
475 case WebURLRequest::FetchRedirectModeFollow: | |
476 return "follow"; | |
477 case WebURLRequest::FetchRedirectModeError: | |
478 return "error"; | |
479 case WebURLRequest::FetchRedirectModeManual: | |
480 return "manual"; | |
481 } | |
482 ASSERT_NOT_REACHED(); | |
483 return ""; | |
484 } | |
485 | |
456 Request* Request::clone(ExceptionState& exceptionState) | 486 Request* Request::clone(ExceptionState& exceptionState) |
457 { | 487 { |
458 if (bodyUsed()) { | 488 if (bodyUsed()) { |
459 exceptionState.throwTypeError("Request body is already used"); | 489 exceptionState.throwTypeError("Request body is already used"); |
460 return nullptr; | 490 return nullptr; |
461 } | 491 } |
462 | 492 |
463 FetchRequestData* request = m_request->clone(executionContext()); | 493 FetchRequestData* request = m_request->clone(executionContext()); |
464 Headers* headers = Headers::create(request->headerList()); | 494 Headers* headers = Headers::create(request->headerList()); |
465 headers->setGuard(m_headers->guard()); | 495 headers->setGuard(m_headers->guard()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 } | 533 } |
504 | 534 |
505 DEFINE_TRACE(Request) | 535 DEFINE_TRACE(Request) |
506 { | 536 { |
507 Body::trace(visitor); | 537 Body::trace(visitor); |
508 visitor->trace(m_request); | 538 visitor->trace(m_request); |
509 visitor->trace(m_headers); | 539 visitor->trace(m_headers); |
510 } | 540 } |
511 | 541 |
512 } // namespace blink | 542 } // namespace blink |
OLD | NEW |