@johntalton/http-util 5.1.5 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -7
- package/package.json +11 -5
- package/src/body.js +8 -8
- package/src/{response/defs.js → defs.js} +2 -1
- package/src/{accept-encoding.js → headers/accept-encoding.js} +2 -2
- package/src/{accept-language.js → headers/accept-language.js} +4 -5
- package/src/{accept.js → headers/accept.js} +18 -26
- package/src/headers/client-hints.js +81 -0
- package/src/{conditional.js → headers/conditional.js} +21 -12
- package/src/{content-disposition.js → headers/content-disposition.js} +26 -25
- package/src/{content-range.js → headers/content-range.js} +1 -1
- package/src/headers/content-type.js +101 -0
- package/src/{fetch-metadata.js → headers/fetch-metadata.js} +0 -1
- package/src/{forwarded.js → headers/forwarded.js} +6 -23
- package/src/{index.js → headers/index.js} +4 -1
- package/src/{multipart.js → headers/multipart.js} +6 -5
- package/src/{preference.js → headers/preference.js} +3 -15
- package/src/{range.js → headers/range.js} +1 -1
- package/src/{server-timing.js → headers/server-timing.js} +2 -2
- package/src/headers/strict-transport-security.js +38 -0
- package/src/{accept-util.js → headers/util/accept-util.js} +8 -14
- package/src/headers/util/index.js +7 -0
- package/src/headers/util/kvp.js +79 -0
- package/src/headers/util/mime.js +77 -0
- package/src/headers/util/whitespace.js +6 -0
- package/src/{www-authenticate.js → headers/www-authenticate.js} +1 -1
- package/src/response/{accepted.js → 2xx/accepted.js} +2 -2
- package/src/response/{bytes.js → 2xx/bytes.js} +5 -5
- package/src/response/{created.js → 2xx/created.js} +4 -4
- package/src/response/{json.js → 2xx/json.js} +5 -5
- package/src/response/{no-content.js → 2xx/no-content.js} +4 -4
- package/src/response/{partial-content.js → 2xx/partial-content.js} +9 -9
- package/src/response/{preflight.js → 2xx/preflight.js} +4 -4
- package/src/response/{sse.js → 2xx/sse.js} +2 -2
- package/src/response/{trace.js → 2xx/trace.js} +3 -3
- package/src/response/{moved-permanently.js → 3xx/moved-permanently.js} +2 -2
- package/src/response/{multiple-choices.js → 3xx/multiple-choices.js} +2 -3
- package/src/response/{not-modified.js → 3xx/not-modified.js} +7 -7
- package/src/response/{permanent-redirect.js → 3xx/permanent-redirect.js} +2 -2
- package/src/response/{see-other.js → 3xx/see-other.js} +2 -2
- package/src/response/{temporary-redirect.js → 3xx/temporary-redirect.js} +2 -2
- package/src/response/{conflict.js → 4xx/conflict.js} +2 -2
- package/src/response/{content-too-large.js → 4xx/content-too-large.js} +2 -2
- package/src/response/{forbidden.js → 4xx/forbidden.js} +3 -2
- package/src/response/{gone.js → 4xx/gone.js} +2 -2
- package/src/response/{im-a-teapot.js → 4xx/im-a-teapot.js} +2 -2
- package/src/response/{not-acceptable.js → 4xx/not-acceptable.js} +3 -3
- package/src/response/{not-allowed.js → 4xx/not-allowed.js} +2 -2
- package/src/response/{not-found.js → 4xx/not-found.js} +3 -3
- package/src/response/{precondition-failed.js → 4xx/precondition-failed.js} +2 -2
- package/src/response/{range-not-satisfiable.js → 4xx/range-not-satisfiable.js} +4 -4
- package/src/response/{timeout.js → 4xx/timeout.js} +2 -2
- package/src/response/{too-many-requests.js → 4xx/too-many-requests.js} +5 -5
- package/src/response/{unauthorized.js → 4xx/unauthorized.js} +4 -4
- package/src/response/{unprocessable.js → 4xx/unprocessable.js} +2 -2
- package/src/response/{unsupported-media.js → 4xx/unsupported-media.js} +3 -3
- package/src/response/{error.js → 5xx/error.js} +3 -3
- package/src/response/{insufficient-storage.js → 5xx/insufficient-storage.js} +2 -2
- package/src/response/{not-implemented.js → 5xx/not-implemented.js} +4 -4
- package/src/response/{unavailable.js → 5xx/unavailable.js} +4 -4
- package/src/response/header-util.js +2 -2
- package/src/response/index.js +35 -35
- package/src/response/response.js +34 -34
- package/src/response/send-util.js +11 -13
- package/src/content-type.js +0 -148
- /package/src/{cache-control.js → headers/cache-control.js} +0 -0
- /package/src/{clear-site-data.js → headers/clear-site-data.js} +0 -0
- /package/src/{link.js → headers/link.js} +0 -0
- /package/src/{rate-limit.js → headers/rate-limit.js} +0 -0
- /package/src/{quote.js → headers/util/quote.js} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CacheControl } from '
|
|
4
|
-
import { Conditional } from '
|
|
5
|
-
import { send } from '
|
|
3
|
+
import { CacheControl } from '../../headers/cache-control.js'
|
|
4
|
+
import { Conditional } from '../../headers/conditional.js'
|
|
5
|
+
import { send } from '../send-util.js'
|
|
6
6
|
|
|
7
7
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
8
|
-
/** @import { Metadata } from '
|
|
9
|
-
/** @import { EtagItem } from '
|
|
10
|
-
/** @import { CacheControlOptions } from '
|
|
8
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
9
|
+
/** @import { EtagItem } from '../../headers/conditional.js' */
|
|
10
|
+
/** @import { CacheControlOptions } from '../../headers/cache-control.js' */
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
13
|
HTTP2_HEADER_AGE,
|
|
@@ -30,6 +30,6 @@ export function sendNotModified(stream, etag, age, cacheControl, meta) {
|
|
|
30
30
|
[HTTP2_HEADER_VARY]: 'Accept, Accept-Encoding',
|
|
31
31
|
[HTTP2_HEADER_CACHE_CONTROL]: CacheControl.encode(cacheControl),
|
|
32
32
|
[HTTP2_HEADER_ETAG]: Conditional.encodeEtag(etag),
|
|
33
|
-
[HTTP2_HEADER_AGE]: age
|
|
33
|
+
[HTTP2_HEADER_AGE]: age === undefined ? undefined : `${age}`
|
|
34
34
|
}, [ HTTP2_HEADER_AGE ], undefined, undefined, meta)
|
|
35
35
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
HTTP2_HEADER_LOCATION
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
HTTP2_HEADER_LOCATION
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
HTTP2_HEADER_LOCATION
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const { HTTP_STATUS_CONFLICT } = http2.constants
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const { HTTP_STATUS_PAYLOAD_TOO_LARGE } = http2.constants
|
|
9
9
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { send } from '../send-util.js'
|
|
3
4
|
|
|
4
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
5
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
6
7
|
|
|
7
8
|
const { HTTP_STATUS_FORBIDDEN} = http2.constants
|
|
8
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const { HTTP_STATUS_GONE } = http2.constants
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const { HTTP_STATUS_TEAPOT } = http2.constants
|
|
9
9
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CONTENT_TYPE_JSON } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { CONTENT_TYPE_JSON } from '../../headers/content-type.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
8
|
|
|
9
9
|
const { HTTP_STATUS_NOT_ACCEPTABLE } = http2.constants
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
HTTP_STATUS_METHOD_NOT_ALLOWED
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CONTENT_TYPE_TEXT } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { CONTENT_TYPE_TEXT } from '../../headers/content-type.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
8
|
|
|
9
9
|
const { HTTP_STATUS_NOT_FOUND } = http2.constants
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const { HTTP_STATUS_PRECONDITION_FAILED } = http2.constants
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CONTENT_RANGE_UNKNOWN, ContentRange } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { CONTENT_RANGE_UNKNOWN, ContentRange } from '../../headers/content-range.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
8
|
-
/** @import { ContentRangeDirective} from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
|
+
/** @import { ContentRangeDirective} from '../../headers/content-range.js' */
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
HTTP2_HEADER_CONTENT_RANGE
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
HTTP_STATUS_REQUEST_TIMEOUT
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CONTENT_TYPE_TEXT } from '
|
|
3
|
+
import { CONTENT_TYPE_TEXT } from '../../headers/content-type.js'
|
|
4
4
|
import {
|
|
5
5
|
HTTP_HEADER_RATE_LIMIT,
|
|
6
6
|
HTTP_HEADER_RATE_LIMIT_POLICY,
|
|
7
7
|
RateLimit,
|
|
8
8
|
RateLimitPolicy
|
|
9
|
-
} from '
|
|
10
|
-
import { send } from '
|
|
9
|
+
} from '../../headers/rate-limit.js'
|
|
10
|
+
import { send } from '../send-util.js'
|
|
11
11
|
|
|
12
12
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
13
|
-
/** @import { Metadata } from '
|
|
14
|
-
/** @import { RateLimitInfo, RateLimitPolicyInfo } from '
|
|
13
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
14
|
+
/** @import { RateLimitInfo, RateLimitPolicyInfo } from '../../headers/rate-limit.js' */
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
17
|
HTTP2_HEADER_RETRY_AFTER
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { Challenge } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { Challenge } from '../../headers/www-authenticate.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
8
|
-
/** @import { ChallengeItem } from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
|
+
/** @import { ChallengeItem } from '../../headers/www-authenticate.js' */
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
HTTP2_HEADER_WWW_AUTHENTICATE
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const { HTTP_STATUS_UNPROCESSABLE_ENTITY } = http2.constants
|
|
9
9
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { HTTP_HEADER_ACCEPT_PATCH, HTTP_HEADER_ACCEPT_POST, HTTP_HEADER_ACCEPT_QUERY } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { HTTP_HEADER_ACCEPT_PATCH, HTTP_HEADER_ACCEPT_POST, HTTP_HEADER_ACCEPT_QUERY } from '../../defs.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
8
|
|
|
9
9
|
const { HTTP2_METHOD_POST, HTTP2_METHOD_PATCH } = http2.constants
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CONTENT_TYPE_TEXT } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { CONTENT_TYPE_TEXT } from '../../headers/content-type.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
8
|
|
|
9
9
|
const { HTTP_STATUS_INTERNAL_SERVER_ERROR } = http2.constants
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { send } from '
|
|
3
|
+
import { send } from '../send-util.js'
|
|
4
4
|
|
|
5
5
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
6
|
-
/** @import { Metadata } from '
|
|
6
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
7
7
|
|
|
8
8
|
const { HTTP_STATUS_INSUFFICIENT_STORAGE } = http2.constants
|
|
9
9
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CONTENT_TYPE_TEXT } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { CONTENT_TYPE_TEXT } from '../../headers/content-type.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
8
|
|
|
9
9
|
const { HTTP_STATUS_NOT_IMPLEMENTED } = http2.constants
|
|
10
10
|
|
|
@@ -15,4 +15,4 @@ const { HTTP_STATUS_NOT_IMPLEMENTED } = http2.constants
|
|
|
15
15
|
*/
|
|
16
16
|
export function sendNotImplemented(stream, message, meta) {
|
|
17
17
|
send(stream, HTTP_STATUS_NOT_IMPLEMENTED, {}, [], CONTENT_TYPE_TEXT, message, meta)
|
|
18
|
-
}
|
|
18
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import http2 from 'node:http2'
|
|
2
2
|
|
|
3
|
-
import { CONTENT_TYPE_TEXT } from '
|
|
4
|
-
import { send } from '
|
|
3
|
+
import { CONTENT_TYPE_TEXT } from '../../headers/content-type.js'
|
|
4
|
+
import { send } from '../send-util.js'
|
|
5
5
|
|
|
6
6
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
7
|
-
/** @import { Metadata } from '
|
|
7
|
+
/** @import { Metadata } from '../../defs.js' */
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
10
|
HTTP2_HEADER_RETRY_AFTER
|
|
@@ -22,4 +22,4 @@ export function sendUnavailable(stream, message, retryAfter, meta) {
|
|
|
22
22
|
send(stream, HTTP_STATUS_SERVICE_UNAVAILABLE, {
|
|
23
23
|
[HTTP2_HEADER_RETRY_AFTER]: Number.isInteger(retryAfter) ? `${retryAfter}` : undefined
|
|
24
24
|
}, [ HTTP2_HEADER_RETRY_AFTER ], CONTENT_TYPE_TEXT, message, meta)
|
|
25
|
-
}
|
|
25
|
+
}
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
HTTP_HEADER_SERVER_TIMING,
|
|
5
5
|
HTTP_HEADER_TIMING_ALLOW_ORIGIN,
|
|
6
6
|
ServerTiming
|
|
7
|
-
} from '../server-timing.js'
|
|
7
|
+
} from '../headers/server-timing.js'
|
|
8
8
|
|
|
9
9
|
/** @import { OutgoingHttpHeaders } from 'node:http2' */
|
|
10
|
-
/** @import { Metadata } from '
|
|
10
|
+
/** @import { Metadata } from '../defs.js' */
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
13
|
HTTP2_HEADER_STATUS,
|
package/src/response/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
/** biome-ignore-all lint/performance/noBarrelFile: entry point */
|
|
2
2
|
/** biome-ignore-all lint/performance/noReExportAll: entry point */
|
|
3
|
-
export * from '
|
|
3
|
+
export * from '../defs.js'
|
|
4
4
|
export * from './send-util.js'
|
|
5
5
|
// end common headers
|
|
6
6
|
|
|
7
|
-
export * from './accepted.js'
|
|
8
|
-
export * from './bytes.js'
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
22
|
-
export * from './
|
|
23
|
-
export * from './
|
|
24
|
-
export * from './
|
|
25
|
-
export * from './
|
|
26
|
-
export * from './
|
|
27
|
-
export * from './
|
|
28
|
-
export * from './
|
|
29
|
-
export * from './
|
|
30
|
-
export * from './
|
|
31
|
-
export * from './
|
|
32
|
-
export * from './
|
|
33
|
-
export * from './
|
|
34
|
-
export * from './
|
|
35
|
-
export * from './
|
|
36
|
-
export * from './
|
|
37
|
-
export * from './
|
|
38
|
-
export * from './
|
|
39
|
-
export * from './
|
|
40
|
-
export * from './
|
|
7
|
+
export * from './2xx/accepted.js'
|
|
8
|
+
export * from './2xx/bytes.js'
|
|
9
|
+
export * from './2xx/created.js'
|
|
10
|
+
export * from './2xx/json.js'
|
|
11
|
+
export * from './2xx/no-content.js'
|
|
12
|
+
export * from './2xx/partial-content.js'
|
|
13
|
+
export * from './2xx/preflight.js'
|
|
14
|
+
export * from './2xx/sse.js'
|
|
15
|
+
export * from './2xx/trace.js'
|
|
16
|
+
export * from './3xx/moved-permanently.js'
|
|
17
|
+
export * from './3xx/multiple-choices.js'
|
|
18
|
+
export * from './3xx/not-modified.js'
|
|
19
|
+
export * from './3xx/permanent-redirect.js'
|
|
20
|
+
export * from './3xx/see-other.js'
|
|
21
|
+
export * from './3xx/temporary-redirect.js'
|
|
22
|
+
export * from './4xx/conflict.js'
|
|
23
|
+
export * from './4xx/content-too-large.js'
|
|
24
|
+
export * from './4xx/forbidden.js'
|
|
25
|
+
export * from './4xx/gone.js'
|
|
26
|
+
export * from './4xx/im-a-teapot.js'
|
|
27
|
+
export * from './4xx/not-acceptable.js'
|
|
28
|
+
export * from './4xx/not-allowed.js'
|
|
29
|
+
export * from './4xx/not-found.js'
|
|
30
|
+
export * from './4xx/precondition-failed.js'
|
|
31
|
+
export * from './4xx/range-not-satisfiable.js'
|
|
32
|
+
export * from './4xx/timeout.js'
|
|
33
|
+
export * from './4xx/too-many-requests.js'
|
|
34
|
+
export * from './4xx/unauthorized.js'
|
|
35
|
+
export * from './4xx/unprocessable.js'
|
|
36
|
+
export * from './4xx/unsupported-media.js'
|
|
37
|
+
export * from './5xx/error.js'
|
|
38
|
+
export * from './5xx/insufficient-storage.js'
|
|
39
|
+
export * from './5xx/not-implemented.js'
|
|
40
|
+
export * from './5xx/unavailable.js'
|
package/src/response/response.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { sendAccepted } from './accepted.js'
|
|
2
|
-
import { sendBytes } from './bytes.js'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
1
|
+
import { sendAccepted } from './2xx/accepted.js'
|
|
2
|
+
import { sendBytes } from './2xx/bytes.js'
|
|
3
|
+
import { sendCreated } from './2xx/created.js'
|
|
4
|
+
import { sendJSON_Encoded } from './2xx/json.js'
|
|
5
|
+
import { sendNoContent } from './2xx/no-content.js'
|
|
6
|
+
import { sendPartialContent } from './2xx/partial-content.js'
|
|
7
|
+
import { sendPreflight } from './2xx/preflight.js'
|
|
8
|
+
import { sendSSE } from './2xx/sse.js'
|
|
9
|
+
import { sendTrace } from './2xx/trace.js'
|
|
10
|
+
import { sendMovedPermanently } from './3xx/moved-permanently.js'
|
|
11
|
+
import { sendMultipleChoices } from './3xx/multiple-choices.js'
|
|
12
|
+
import { sendNotModified } from './3xx/not-modified.js'
|
|
13
|
+
import { sendPermanentRedirect } from './3xx/permanent-redirect.js'
|
|
14
|
+
import { sendSeeOther } from './3xx/see-other.js'
|
|
15
|
+
import { sendTemporaryRedirect } from './3xx/temporary-redirect.js'
|
|
16
|
+
import { sendConflict } from './4xx/conflict.js'
|
|
17
|
+
import { sendContentTooLarge } from './4xx/content-too-large.js'
|
|
18
|
+
import { sendForbidden } from './4xx/forbidden.js'
|
|
19
|
+
import { sendGone } from './4xx/gone.js'
|
|
20
|
+
import { sendImATeapot } from './4xx/im-a-teapot.js'
|
|
21
|
+
import { sendNotAcceptable } from './4xx/not-acceptable.js'
|
|
22
|
+
import { sendNotAllowed } from './4xx/not-allowed.js'
|
|
23
|
+
import { sendNotFound } from './4xx/not-found.js'
|
|
24
|
+
import { sendPreconditionFailed } from './4xx/precondition-failed.js'
|
|
25
|
+
import { sendRangeNotSatisfiable } from './4xx/range-not-satisfiable.js'
|
|
26
|
+
import { sendTimeout } from './4xx/timeout.js'
|
|
27
|
+
import { sendTooManyRequests } from './4xx/too-many-requests.js'
|
|
28
|
+
import { sendUnauthorized } from './4xx/unauthorized.js'
|
|
29
|
+
import { sendUnprocessable } from './4xx/unprocessable.js'
|
|
30
|
+
import { sendUnsupportedMediaType } from './4xx/unsupported-media.js'
|
|
31
|
+
import { sendError } from './5xx/error.js'
|
|
32
|
+
import { sendInsufficientStorage } from './5xx/insufficient-storage.js'
|
|
33
|
+
import { sendNotImplemented } from './5xx/not-implemented.js'
|
|
34
|
+
import { sendUnavailable } from './5xx/unavailable.js'
|
|
35
35
|
|
|
36
36
|
export const Response = {
|
|
37
37
|
accepted: sendAccepted,
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
zstdCompressSync
|
|
9
9
|
} from 'node:zlib'
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
11
|
+
import { HTTP_HEADER_ACCEPT_QUERY } from '../defs.js'
|
|
12
|
+
import { CacheControl } from '../headers/cache-control.js'
|
|
13
|
+
import { Conditional } from '../headers/conditional.js'
|
|
14
|
+
import { ContentRange } from '../headers/content-range.js'
|
|
15
|
+
import { CHARSET_UTF8 } from '../headers/content-type.js'
|
|
16
16
|
import {
|
|
17
17
|
coreHeaders,
|
|
18
18
|
customHeaders,
|
|
@@ -22,12 +22,10 @@ import {
|
|
|
22
22
|
/** @import { ServerHttp2Stream } from 'node:http2' */
|
|
23
23
|
/** @import { OutgoingHttpHeaders } from 'node:http2' */
|
|
24
24
|
/** @import { InputType } from 'node:zlib' */
|
|
25
|
-
/** @import { Metadata } from '
|
|
26
|
-
/** @import { EtagItem } from '../conditional.js' */
|
|
27
|
-
/** @import { CacheControlOptions } from '../cache-control.js' */
|
|
28
|
-
/** @import { ContentRangeDirective } from '../content-range.js' */
|
|
29
|
-
|
|
30
|
-
/** @typedef {ArrayBufferLike|ArrayBufferView|ReadableStream|string} SendBody */
|
|
25
|
+
/** @import { Metadata, SendBody } from '../defs.js' */
|
|
26
|
+
/** @import { EtagItem } from '../headers/conditional.js' */
|
|
27
|
+
/** @import { CacheControlOptions } from '../headers/cache-control.js' */
|
|
28
|
+
/** @import { ContentRangeDirective } from '../headers/content-range.js' */
|
|
31
29
|
|
|
32
30
|
const {
|
|
33
31
|
HTTP_STATUS_INTERNAL_SERVER_ERROR,
|
|
@@ -76,7 +74,7 @@ export function send_encoded(stream, status, contentType, body, encoding, etag,
|
|
|
76
74
|
const obj = (typeof body === 'string') ? Buffer.from(body, CHARSET_UTF8) : body
|
|
77
75
|
|
|
78
76
|
const useIdentity = encoding === 'identity'
|
|
79
|
-
const encoder = encoding
|
|
77
|
+
const encoder = encoding === undefined ? undefined : ENCODER_MAP.get(encoding)
|
|
80
78
|
const hasEncoder = encoder !== undefined
|
|
81
79
|
const actualEncoding = hasEncoder ? encoding : undefined
|
|
82
80
|
|
|
@@ -125,7 +123,7 @@ export function send_bytes(stream, status, contentType, obj, range, contentLengt
|
|
|
125
123
|
[HTTP2_HEADER_VARY]: varyHeaders.join(','),
|
|
126
124
|
[HTTP2_HEADER_CACHE_CONTROL]: CacheControl.encode(cacheControl),
|
|
127
125
|
[HTTP2_HEADER_ETAG]: Conditional.encodeEtag(etag),
|
|
128
|
-
[HTTP2_HEADER_AGE]: age
|
|
126
|
+
[HTTP2_HEADER_AGE]: age === undefined ? undefined : `${age}`,
|
|
129
127
|
[HTTP2_HEADER_CONTENT_LENGTH]: contentLen,
|
|
130
128
|
[HTTP2_HEADER_CONTENT_RANGE]: ContentRange.encode(range),
|
|
131
129
|
[HTTP2_HEADER_ACCEPT_RANGES]: acceptRanges,
|