Added error handling for non-CORS requests.

This commit is contained in:
n1474335 2017-06-09 14:53:15 +00:00
parent 52426bc1a4
commit 127364e8a4
2 changed files with 5 additions and 1 deletions

View File

@ -3407,7 +3407,7 @@ const OperationConfig = {
"<br><br>",
"You can add headers line by line in the format <code>Key: Value</code>",
"<br><br>",
"This operation will throw an error for any status code that is not 200, unless the 'Ignore status code' option is checked.",
"The status code of the response, along with a limited selection of exposed headers, can be viewed by checking the 'Show response metadata' option. Only a limited set of response headers are exposed by the browser for security reasons.",
].join("\n"),
run: HTTP.runHTTPRequest,
inputType: "string",

View File

@ -126,6 +126,10 @@ const HTTP = {
return fetch(url, config)
.then(r => {
if (r.status === 0 && r.type === "opaque") {
return "Error: Null response. Try setting the connection mode to CORS.";
}
if (showResponseMetadata) {
let headers = "";
for (let pair of r.headers.entries()) {