1 | const mkResponse = (status, statusText) => (body = null, init = {}) => new Response(body, {
|
2 | ...init,
|
3 | status,
|
4 | statusText,
|
5 | });
|
6 | const mkRedirect = (status, statusText) => (location, init = {}) => new Response(null, {
|
7 | ...init,
|
8 | status,
|
9 | statusText,
|
10 | headers: [
|
11 | ...(init === null || init === void 0 ? void 0 : init.headers) ? Array.isArray(init.headers) ? init.headers : new Headers(init.headers) : [],
|
12 | ['Location', location.toString()],
|
13 | ],
|
14 | });
|
15 | const mkUnauthorized = (status, statusText) => (realm = '', init = {}) => new Response(null, {
|
16 | ...init,
|
17 | status,
|
18 | statusText,
|
19 | headers: [
|
20 | ...(init === null || init === void 0 ? void 0 : init.headers) ? Array.isArray(init.headers) ? init.headers : new Headers(init.headers) : [],
|
21 | ['WWW-Authenticate', `Basic realm="${realm}", charset="UTF-8"`],
|
22 | ],
|
23 | });
|
24 | const mkNotModified = (status, statusText) => (ifNoneMatch, ifModifiedSince, init = {}) => new Response(null, {
|
25 | ...init,
|
26 | status,
|
27 | statusText,
|
28 | headers: [
|
29 | ...(init === null || init === void 0 ? void 0 : init.headers) ? Array.isArray(init.headers) ? init.headers : new Headers(init.headers) : [],
|
30 | ['If-None-Match', ifNoneMatch],
|
31 | ['If-Modified-Since', ifModifiedSince.toUTCString()],
|
32 | ],
|
33 | });
|
34 | export const ok = mkResponse(200, 'OK');
|
35 | export const created = mkResponse(201, 'Created');
|
36 | export const accepted = mkResponse(202, 'Accepted');
|
37 | export const nonAuthoritativeInformation = mkResponse(203, 'Non-Authoritative Information');
|
38 | export const noContent = mkResponse(204, 'No Content');
|
39 | export const resetContent = mkResponse(205, 'Reset Content');
|
40 | export const partialContent = mkResponse(206, 'Partial Content');
|
41 | export const multiStatus = mkResponse(207, 'Multi-Status');
|
42 | export const alreadyReported = mkResponse(208, 'Already Reported');
|
43 | export const imUsed = mkResponse(226, 'IM Used');
|
44 | export const multipleChoices = mkRedirect(300, 'Multiple Choices');
|
45 | export const movedPermanently = mkRedirect(301, 'Moved Permanently');
|
46 | export const found = mkRedirect(302, 'Found');
|
47 | export const seeOther = mkRedirect(303, 'See Other');
|
48 | export const notModified = mkNotModified(304, 'Not Modified');
|
49 | export const temporaryRedirect = mkRedirect(307, 'Temporary Redirect');
|
50 | export const permanentRedirect = mkRedirect(308, 'Permanent Redirect');
|
51 | export const badRequest = mkResponse(400, 'Bad Request');
|
52 | export const unauthorized = mkUnauthorized(401, 'Unauthorized');
|
53 | export const paymentRequired = mkResponse(402, 'Payment Required');
|
54 | export const forbidden = mkResponse(403, 'Forbidden');
|
55 | export const notFound = mkResponse(404, 'Not Found');
|
56 | export const methodNotAllowed = mkResponse(405, 'Method Not Allowed');
|
57 | export const notAcceptable = mkResponse(406, 'Not Acceptable');
|
58 | export const proxyAuthenticationRequired = mkResponse(407, 'Proxy Authentication Required');
|
59 | export const requestTimeout = mkResponse(408, 'Request Timeout');
|
60 | export const conflict = mkResponse(409, 'Conflict');
|
61 | export const gone = mkResponse(410, 'Gone');
|
62 | export const lengthRequired = mkResponse(411, 'Length Required');
|
63 | export const preconditionFailed = mkResponse(412, 'Precondition Failed');
|
64 | export const payloadTooLarge = mkResponse(413, 'Payload Too Large');
|
65 | export const uriTooLong = mkResponse(414, 'URI Too Long');
|
66 | export const unsupportedMediaType = mkResponse(415, 'Unsupported Media Type');
|
67 | export const rangeNotSatisfiable = mkResponse(416, 'Range Not Satisfiable');
|
68 | export const expectationFailed = mkResponse(417, 'Expectation Failed');
|
69 | export const imATeapot = mkResponse(418, 'I\'m a teapot');
|
70 | export const misdirectedRequest = mkResponse(421, 'Misdirected Request');
|
71 | export const unprocessableEntity = mkResponse(422, 'Unprocessable Entity');
|
72 | export const locked = mkResponse(423, 'Locked');
|
73 | export const failedDependency = mkResponse(424, 'Failed Dependency');
|
74 | export const tooEarly = mkResponse(425, 'Too Early');
|
75 | export const upgradeRequired = mkResponse(426, 'Upgrade Required');
|
76 | export const preconditionRequired = mkResponse(428, 'Precondition Required');
|
77 | export const tooManyRequests = mkResponse(429, 'Too Many Requests');
|
78 | export const requestHeaderFieldsTooLarge = mkResponse(431, 'Request Header Fields Too Large');
|
79 | export const unavailableForLegalReasons = mkResponse(451, 'Unavailable For Legal Reasons');
|
80 | export const internalServerError = mkResponse(500, 'Internal Server Error');
|
81 | export const notImplemented = mkResponse(501, 'Not Implemented');
|
82 | export const badGateway = mkResponse(502, 'Bad Gateway');
|
83 | export const serviceUnavailable = mkResponse(503, 'Service Unavailable');
|
84 | export const gatewayTimeout = mkResponse(504, 'Gateway Timeout');
|
85 | export const httpVersionNotSupported = mkResponse(505, 'HTTP Version Not Supported');
|
86 | export const variantAlsoNegotiates = mkResponse(506, 'Variant Also Negotiates');
|
87 | export const insufficientStorage = mkResponse(507, 'Insufficient Storage');
|
88 | export const loopDetected = mkResponse(508, 'Loop Detected');
|
89 | export const notExtended = mkResponse(510, 'Not Extended');
|
90 | export const networkAuthenticationRequired = mkResponse(511, 'Network Authentication Required');
|
91 |
|
\ | No newline at end of file |