1
0
Fork 0
fetch-compare/fixtures/request.js

52 lines
986 B
JavaScript
Raw Normal View History

2021-09-09 23:47:04 +08:00
/* eslint-disable no-new */
const tests = {
request: {
2021-09-10 01:55:07 +08:00
async unexpectedPercent() {
2021-09-09 23:47:04 +08:00
try {
new Request('http://example.com%');
2021-09-10 01:55:07 +08:00
return null;
2021-09-10 00:37:10 +08:00
} catch (error) {
2021-09-10 01:55:07 +08:00
return error.toString();
2021-09-10 00:37:10 +08:00
}
},
async rejectCredentials() {
try {
new Request('http://user:pass@example.com');
2021-09-10 01:55:07 +08:00
return null;
2021-09-10 00:37:10 +08:00
} catch (error) {
2021-09-10 01:55:07 +08:00
return error.toString();
}
},
async rejectBodyInGET() {
try {
new Request('http://example.com', {body: 'a'});
return null;
} catch (error) {
return error.toString();
}
},
async rejectEmptyBodyInGET() {
try {
new Request('http://example.com', {body: ''});
return null;
} catch (error) {
return error.toString();
}
},
async acceptContentLength() {
try {
new Request('http://example.com', {
headers: {
'Content-Length': 0,
},
});
return null;
} catch (error) {
return error.toString();
2021-09-09 23:47:04 +08:00
}
},
},
};
export default tests;
/* eslint-enable no-new */