Changeset 205253 in webkit
- Timestamp:
- Aug 31, 2016 9:44:49 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r205248 r205253 1 2016-08-31 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request construction failure should not set "bodyUsed" 4 https://bugs.webkit.org/show_bug.cgi?id=161432 5 6 Reviewed by Alex Christensen. 7 8 * web-platform-tests/fetch/api/request/request-disturbed-expected.txt: 9 * web-platform-tests/fetch/api/request/request-disturbed.html: 10 1 11 2016-08-31 Romain Bellessort <romain.bellessort@crf.canon.fr> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-disturbed-expected.txt
r195954 r205253 5 5 PASS Input request used for creating new request became disturbed 6 6 PASS Check consuming a disturbed request 7 PASS Request construction failure should not set "bodyUsed" 7 8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-disturbed.html
r195954 r205253 51 51 return promise_rejects(test, new TypeError(), bodyConsumed.blob()); 52 52 }, "Check consuming a disturbed request"); 53 54 test(function() { 55 var req = new Request(URL, {method: 'POST', body: 'hello'}); 56 assert_false(req.bodyUsed, 57 'Request should not be flagged as used if it has not been ' + 58 'consumed.'); 59 assert_throws( 60 {name: 'TypeError'}, 61 function() { new Request(req, {method: 'GET'}); }, 62 'A get request may not have body.'); 63 64 assert_false(req.bodyUsed, 'After the GET case'); 65 66 assert_throws( 67 {name: 'TypeError'}, 68 function() { new Request(req, {method: 'CONNECT'}); }, 69 'Request() with a forbidden method must throw.'); 70 71 assert_false(req.bodyUsed, 'After the forbidden method case'); 72 73 var req2 = new Request(req); 74 assert_true(req.bodyUsed, 75 'Request should be flagged as used if it has been consumed.'); 76 }, 'Request construction failure should not set "bodyUsed"'); 53 77 </script> 54 78 </body> -
trunk/Source/WebCore/ChangeLog
r205251 r205253 1 2016-08-31 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request construction failure should not set "bodyUsed" 4 https://bugs.webkit.org/show_bug.cgi?id=161432 5 6 Reviewed by Alex Christensen. 7 8 Covered by added sub-test coming from chromium fetch test suite. 9 10 * Modules/fetch/FetchRequest.cpp: 11 (WebCore::methodCanHaveBody): 12 (WebCore::FetchRequest::setBody): Check whether request can have a body before disturbing the passed request. 13 (WebCore::validateBodyAndMethod): Deleted. 14 1 15 2016-08-31 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r205251 r205253 194 194 } 195 195 196 static bool validateBodyAndMethod(const FetchBody& body, const FetchRequest::InternalRequest& internalRequest) 197 { 198 if (body.isEmpty()) 199 return true; 196 static bool methodCanHaveBody(const FetchRequest::InternalRequest& internalRequest) 197 { 200 198 return internalRequest.request.httpMethod() != "GET" && internalRequest.request.httpMethod() != "HEAD"; 201 199 } … … 258 256 { 259 257 if (!body.isNull()) { 258 if (!methodCanHaveBody(m_internalRequest)) { 259 ec = TypeError; 260 return; 261 } 262 260 263 ASSERT(scriptExecutionContext()); 261 264 m_body = FetchBody::extract(*scriptExecutionContext(), execState, body); … … 266 269 } 267 270 else if (request && !request->m_body.isEmpty()) { 271 if (!methodCanHaveBody(m_internalRequest)) { 272 ec = TypeError; 273 return; 274 } 275 268 276 m_body = FetchBody::extractFromBody(&request->m_body); 269 277 request->setDisturbed(); … … 271 279 272 280 m_body.updateContentType(m_headers); 273 274 if (!validateBodyAndMethod(m_body, m_internalRequest))275 ec = TypeError;276 281 } 277 282
Note: See TracChangeset
for help on using the changeset viewer.