[Webkit-unassigned] [Bug 212858] Request object's text, json, arrayBuffer function do not work even though devtools shows that request the request object has these properties.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Jun 8 15:12:07 PDT 2020
https://bugs.webkit.org/show_bug.cgi?id=212858
--- Comment #4 from Peter W <peter.b.wu at oracle.com> ---
The following is a test case to reproduce the issue where options such as .text(),.arrayBuffer(), .json(), and .formData() do no work. Note when the body is an instance of FormData, the above methods of inspecting the body element are inaccessible and throw a NotSupportError. When the body is a FormData Object, even the .formData() returns a NotSupportedError.
~~~
var formDataObj = new FormData();
formDataObj.append('key','value')
var requestOptions = {
cache: "default",
credentials: "same-origin",
method: "POST",
mode: "cors"
}
var requestOptionsString = {
body: "text",
cache: "default",
credentials: "same-origin",
method: "POST",
mode: "cors"
}
var requestOptionsJSON = {
body: {"key":"value"},
cache: "default",
credentials: "same-origin",
method: "POST",
mode: "cors"
}
var requestOptionsFD = {
body: formDataObj,
cache: "default",
credentials: "same-origin",
method: "POST",
mode: "cors"
}
function requestTest(input,options){
var request = new Request(input,options)
request.clone().formData().then(formData=>console.log("formData",input,formData)).catch(err=>console.log("noFormData",input,err))
request.clone().json().then(json=>console.log("json",input,JSON.stringify(json))).catch(err=>console.log("noJson",input,err))
request.clone().text().then(text=>console.log("text",input,text)).catch(err=>console.log("noText",input,err))
request.clone().arrayBuffer().then(arrayBuffer=>console.log("arrayBuffer",input,arrayBuffer)).catch(err=>console.log("noArrayBuffer",input,err))
request.clone().blob().then(blob=>console.log("blob",input,blob)).catch(err=>console.log("noBlob",input,err))
fetch(request).then(response=>console.log("response",input,response)).catch(error=>console.log("error",input,error))
}
requestTest('none',requestOptions)
requestTest('string',requestOptionsString)
requestTest('json',requestOptionsJSON)
requestTest('formData',requestOptionsFD)
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200608/e29c55c5/attachment.htm>
More information about the webkit-unassigned
mailing list