Add more headers
parent
a18e3b6dbb
commit
6a8a07deef
|
@ -1,16 +1,85 @@
|
||||||
const tests = {
|
const tests = {
|
||||||
fetch: {
|
fetch: {
|
||||||
|
async acceptCookie() {
|
||||||
|
try {
|
||||||
|
const ctrl = new AbortController();
|
||||||
|
setTimeout(() => ctrl.abort(), 5000);
|
||||||
|
const response = await fetch('https://httpbin.org/get', {
|
||||||
|
headers: {'Cookie': 'overwrote-cookie'},
|
||||||
|
signal: ctrl.signal,
|
||||||
|
});
|
||||||
|
const o = await response.json();
|
||||||
|
return `Cookie: ${o.headers['Cookie']}`;
|
||||||
|
} catch (error) {
|
||||||
|
return error.toString();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async acceptReferer() {
|
||||||
|
try {
|
||||||
|
const ctrl = new AbortController();
|
||||||
|
setTimeout(() => ctrl.abort(), 5000);
|
||||||
|
const response = await fetch('https://httpbin.org/get', {
|
||||||
|
headers: {'Referer': 'overwrote-referer'},
|
||||||
|
signal: ctrl.signal,
|
||||||
|
});
|
||||||
|
const o = await response.json();
|
||||||
|
return `Referer: ${o.headers['Referer']}`;
|
||||||
|
} catch (error) {
|
||||||
|
return error.toString();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async acceptKeepAlive() {
|
||||||
|
try {
|
||||||
|
const ctrl = new AbortController();
|
||||||
|
setTimeout(() => ctrl.abort(), 5000);
|
||||||
|
const response = await fetch('https://httpbin.org/get', {
|
||||||
|
headers: {'Keep-Alive': 'timeout=5, max=1000'},
|
||||||
|
signal: ctrl.signal,
|
||||||
|
});
|
||||||
|
const o = await response.json();
|
||||||
|
return `Keep-Alive: ${o.headers['Keep-Alive']}`;
|
||||||
|
} catch (error) {
|
||||||
|
return error.toString();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async acceptDate() {
|
||||||
|
try {
|
||||||
|
const ctrl = new AbortController();
|
||||||
|
setTimeout(() => ctrl.abort(), 5000);
|
||||||
|
const response = await fetch('https://httpbin.org/get', {
|
||||||
|
headers: {'Date': 'overwrote-date'},
|
||||||
|
signal: ctrl.signal,
|
||||||
|
});
|
||||||
|
const o = await response.json();
|
||||||
|
return `Date: ${o.headers['Date']}`;
|
||||||
|
} catch (error) {
|
||||||
|
return error.toString();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async acceptHost() {
|
||||||
|
try {
|
||||||
|
const ctrl = new AbortController();
|
||||||
|
setTimeout(() => ctrl.abort(), 5000);
|
||||||
|
const response = await fetch('https://httpbin.org/get', {
|
||||||
|
headers: {'Host': 'overwrote-host.example.com'},
|
||||||
|
signal: ctrl.signal,
|
||||||
|
});
|
||||||
|
const o = await response.json();
|
||||||
|
return `Host: ${o.headers['Host']}`;
|
||||||
|
} catch (error) {
|
||||||
|
return error.toString();
|
||||||
|
}
|
||||||
|
},
|
||||||
async acceptContentLength() {
|
async acceptContentLength() {
|
||||||
try {
|
try {
|
||||||
const ctrl = new AbortController();
|
const ctrl = new AbortController();
|
||||||
setTimeout(() => ctrl.abort(), 5000);
|
setTimeout(() => ctrl.abort(), 5000);
|
||||||
const response = await fetch('https://httpbin.org/get', {
|
const response = await fetch('https://httpbin.org/get', {
|
||||||
headers: {'Content-Length': 2},
|
headers: {'Content-Length': '2'},
|
||||||
signal: ctrl.signal,
|
signal: ctrl.signal,
|
||||||
});
|
});
|
||||||
const o = await response.json();
|
const o = await response.json();
|
||||||
const length = o.headers['Content-Length'];
|
return `Content-Length: ${o.headers['Content-Length']}`;
|
||||||
return `Content-Length: ${length}`;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error.toString();
|
return error.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue