@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.
Files changed (70) hide show
  1. package/README.md +54 -7
  2. package/package.json +11 -5
  3. package/src/body.js +8 -8
  4. package/src/{response/defs.js → defs.js} +2 -1
  5. package/src/{accept-encoding.js → headers/accept-encoding.js} +2 -2
  6. package/src/{accept-language.js → headers/accept-language.js} +4 -5
  7. package/src/{accept.js → headers/accept.js} +18 -26
  8. package/src/headers/client-hints.js +81 -0
  9. package/src/{conditional.js → headers/conditional.js} +21 -12
  10. package/src/{content-disposition.js → headers/content-disposition.js} +26 -25
  11. package/src/{content-range.js → headers/content-range.js} +1 -1
  12. package/src/headers/content-type.js +101 -0
  13. package/src/{fetch-metadata.js → headers/fetch-metadata.js} +0 -1
  14. package/src/{forwarded.js → headers/forwarded.js} +6 -23
  15. package/src/{index.js → headers/index.js} +4 -1
  16. package/src/{multipart.js → headers/multipart.js} +6 -5
  17. package/src/{preference.js → headers/preference.js} +3 -15
  18. package/src/{range.js → headers/range.js} +1 -1
  19. package/src/{server-timing.js → headers/server-timing.js} +2 -2
  20. package/src/headers/strict-transport-security.js +38 -0
  21. package/src/{accept-util.js → headers/util/accept-util.js} +8 -14
  22. package/src/headers/util/index.js +7 -0
  23. package/src/headers/util/kvp.js +79 -0
  24. package/src/headers/util/mime.js +77 -0
  25. package/src/headers/util/whitespace.js +6 -0
  26. package/src/{www-authenticate.js → headers/www-authenticate.js} +1 -1
  27. package/src/response/{accepted.js → 2xx/accepted.js} +2 -2
  28. package/src/response/{bytes.js → 2xx/bytes.js} +5 -5
  29. package/src/response/{created.js → 2xx/created.js} +4 -4
  30. package/src/response/{json.js → 2xx/json.js} +5 -5
  31. package/src/response/{no-content.js → 2xx/no-content.js} +4 -4
  32. package/src/response/{partial-content.js → 2xx/partial-content.js} +9 -9
  33. package/src/response/{preflight.js → 2xx/preflight.js} +4 -4
  34. package/src/response/{sse.js → 2xx/sse.js} +2 -2
  35. package/src/response/{trace.js → 2xx/trace.js} +3 -3
  36. package/src/response/{moved-permanently.js → 3xx/moved-permanently.js} +2 -2
  37. package/src/response/{multiple-choices.js → 3xx/multiple-choices.js} +2 -3
  38. package/src/response/{not-modified.js → 3xx/not-modified.js} +7 -7
  39. package/src/response/{permanent-redirect.js → 3xx/permanent-redirect.js} +2 -2
  40. package/src/response/{see-other.js → 3xx/see-other.js} +2 -2
  41. package/src/response/{temporary-redirect.js → 3xx/temporary-redirect.js} +2 -2
  42. package/src/response/{conflict.js → 4xx/conflict.js} +2 -2
  43. package/src/response/{content-too-large.js → 4xx/content-too-large.js} +2 -2
  44. package/src/response/{forbidden.js → 4xx/forbidden.js} +3 -2
  45. package/src/response/{gone.js → 4xx/gone.js} +2 -2
  46. package/src/response/{im-a-teapot.js → 4xx/im-a-teapot.js} +2 -2
  47. package/src/response/{not-acceptable.js → 4xx/not-acceptable.js} +3 -3
  48. package/src/response/{not-allowed.js → 4xx/not-allowed.js} +2 -2
  49. package/src/response/{not-found.js → 4xx/not-found.js} +3 -3
  50. package/src/response/{precondition-failed.js → 4xx/precondition-failed.js} +2 -2
  51. package/src/response/{range-not-satisfiable.js → 4xx/range-not-satisfiable.js} +4 -4
  52. package/src/response/{timeout.js → 4xx/timeout.js} +2 -2
  53. package/src/response/{too-many-requests.js → 4xx/too-many-requests.js} +5 -5
  54. package/src/response/{unauthorized.js → 4xx/unauthorized.js} +4 -4
  55. package/src/response/{unprocessable.js → 4xx/unprocessable.js} +2 -2
  56. package/src/response/{unsupported-media.js → 4xx/unsupported-media.js} +3 -3
  57. package/src/response/{error.js → 5xx/error.js} +3 -3
  58. package/src/response/{insufficient-storage.js → 5xx/insufficient-storage.js} +2 -2
  59. package/src/response/{not-implemented.js → 5xx/not-implemented.js} +4 -4
  60. package/src/response/{unavailable.js → 5xx/unavailable.js} +4 -4
  61. package/src/response/header-util.js +2 -2
  62. package/src/response/index.js +35 -35
  63. package/src/response/response.js +34 -34
  64. package/src/response/send-util.js +11 -13
  65. package/src/content-type.js +0 -148
  66. /package/src/{cache-control.js → headers/cache-control.js} +0 -0
  67. /package/src/{clear-site-data.js → headers/clear-site-data.js} +0 -0
  68. /package/src/{link.js → headers/link.js} +0 -0
  69. /package/src/{rate-limit.js → headers/rate-limit.js} +0 -0
  70. /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 '../cache-control.js'
4
- import { Conditional } from '../conditional.js'
5
- import { send } from './send-util.js'
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 './defs.js' */
9
- /** @import { EtagItem } from '../conditional.js' */
10
- /** @import { CacheControlOptions } from '../cache-control.js' */
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 !== undefined ? `${age}` : undefined
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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
- import { send } from './send-util.js'
2
+
3
+ import { send } from '../send-util.js'
3
4
 
4
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
5
- /** @import { Metadata } from './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 '../content-type.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 '../content-type.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 '../content-range.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
8
- /** @import { ContentRangeDirective} from '../content-range.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 '../content-type.js'
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 '../rate-limit.js'
10
- import { send } from './send-util.js'
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 './defs.js' */
14
- /** @import { RateLimitInfo, RateLimitPolicyInfo } from '../rate-limit.js' */
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 '../www-authenticate.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
8
- /** @import { ChallengeItem } from '../www-authenticate.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 './defs.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
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 '../content-type.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
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 './send-util.js'
3
+ import { send } from '../send-util.js'
4
4
 
5
5
  /** @import { ServerHttp2Stream } from 'node:http2' */
6
- /** @import { Metadata } from './defs.js' */
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 '../content-type.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
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 '../content-type.js'
4
- import { send } from './send-util.js'
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 './defs.js' */
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 './defs.js' */
10
+ /** @import { Metadata } from '../defs.js' */
11
11
 
12
12
  const {
13
13
  HTTP2_HEADER_STATUS,
@@ -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 './defs.js'
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 './conflict.js'
10
- export * from './content-too-large.js'
11
- export * from './created.js'
12
- export * from './error.js'
13
- export * from './forbidden.js'
14
- export * from './gone.js'
15
- export * from './im-a-teapot.js'
16
- export * from './insufficient-storage.js'
17
- export * from './json.js'
18
- export * from './moved-permanently.js'
19
- export * from './multiple-choices.js'
20
- export * from './no-content.js'
21
- export * from './not-acceptable.js'
22
- export * from './not-allowed.js'
23
- export * from './not-found.js'
24
- export * from './not-implemented.js'
25
- export * from './not-modified.js'
26
- export * from './partial-content.js'
27
- export * from './permanent-redirect.js'
28
- export * from './precondition-failed.js'
29
- export * from './preflight.js'
30
- export * from './range-not-satisfiable.js'
31
- export * from './see-other.js'
32
- export * from './sse.js'
33
- export * from './temporary-redirect.js'
34
- export * from './timeout.js'
35
- export * from './too-many-requests.js'
36
- export * from './trace.js'
37
- export * from './unauthorized.js'
38
- export * from './unavailable.js'
39
- export * from './unprocessable.js'
40
- export * from './unsupported-media.js'
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'
@@ -1,37 +1,37 @@
1
- import { sendAccepted } from './accepted.js'
2
- import { sendBytes } from './bytes.js'
3
- import { sendConflict } from './conflict.js'
4
- import { sendContentTooLarge } from './content-too-large.js'
5
- import { sendCreated } from './created.js'
6
- import { sendError } from './error.js'
7
- import { sendForbidden } from './forbidden.js'
8
- import { sendGone } from './gone.js'
9
- import { sendImATeapot } from './im-a-teapot.js'
10
- import { sendInsufficientStorage } from './insufficient-storage.js'
11
- import { sendJSON_Encoded } from './json.js'
12
- import { sendMovedPermanently } from './moved-permanently.js'
13
- import { sendMultipleChoices } from './multiple-choices.js'
14
- import { sendNoContent } from './no-content.js'
15
- import { sendNotAcceptable } from './not-acceptable.js'
16
- import { sendNotAllowed } from './not-allowed.js'
17
- import { sendNotFound } from './not-found.js'
18
- import { sendNotImplemented } from './not-implemented.js'
19
- import { sendNotModified } from './not-modified.js'
20
- import { sendPartialContent } from './partial-content.js'
21
- import { sendPermanentRedirect } from './permanent-redirect.js'
22
- import { sendPreconditionFailed } from './precondition-failed.js'
23
- import { sendPreflight } from './preflight.js'
24
- import { sendRangeNotSatisfiable } from './range-not-satisfiable.js'
25
- import { sendSeeOther } from './see-other.js'
26
- import { sendSSE } from './sse.js'
27
- import { sendTemporaryRedirect } from './temporary-redirect.js'
28
- import { sendTimeout } from './timeout.js'
29
- import { sendTooManyRequests } from './too-many-requests.js'
30
- import { sendTrace } from './trace.js'
31
- import { sendUnauthorized } from './unauthorized.js'
32
- import { sendUnavailable } from './unavailable.js'
33
- import { sendUnprocessable } from './unprocessable.js'
34
- import { sendUnsupportedMediaType } from './unsupported-media.js'
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 { CacheControl } from '../cache-control.js'
12
- import { Conditional } from '../conditional.js'
13
- import { ContentRange } from '../content-range.js'
14
- import { CHARSET_UTF8 } from '../content-type.js'
15
- import { HTTP_HEADER_ACCEPT_QUERY } from './defs.js'
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 './defs.js' */
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 !== undefined ? ENCODER_MAP.get(encoding) : undefined
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 !== undefined ? `${age}` : undefined,
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,