mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
Added error handling for non-CORS requests.
This commit is contained in:
parent
52426bc1a4
commit
127364e8a4
2 changed files with 5 additions and 1 deletions
|
@ -3407,7 +3407,7 @@ const OperationConfig = {
|
||||||
"<br><br>",
|
"<br><br>",
|
||||||
"You can add headers line by line in the format <code>Key: Value</code>",
|
"You can add headers line by line in the format <code>Key: Value</code>",
|
||||||
"<br><br>",
|
"<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"),
|
].join("\n"),
|
||||||
run: HTTP.runHTTPRequest,
|
run: HTTP.runHTTPRequest,
|
||||||
inputType: "string",
|
inputType: "string",
|
||||||
|
|
|
@ -126,6 +126,10 @@ const HTTP = {
|
||||||
|
|
||||||
return fetch(url, config)
|
return fetch(url, config)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
|
if (r.status === 0 && r.type === "opaque") {
|
||||||
|
return "Error: Null response. Try setting the connection mode to CORS.";
|
||||||
|
}
|
||||||
|
|
||||||
if (showResponseMetadata) {
|
if (showResponseMetadata) {
|
||||||
let headers = "";
|
let headers = "";
|
||||||
for (let pair of r.headers.entries()) {
|
for (let pair of r.headers.entries()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue