header.d.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import { Autocomplete } from './utility'
  2. /**
  3. * The header type declaration of `undici`.
  4. */
  5. export type IncomingHttpHeaders = Record<string, string | string[] | undefined>
  6. type HeaderNames = Autocomplete<
  7. | 'Accept'
  8. | 'Accept-CH'
  9. | 'Accept-Charset'
  10. | 'Accept-Encoding'
  11. | 'Accept-Language'
  12. | 'Accept-Patch'
  13. | 'Accept-Post'
  14. | 'Accept-Ranges'
  15. | 'Access-Control-Allow-Credentials'
  16. | 'Access-Control-Allow-Headers'
  17. | 'Access-Control-Allow-Methods'
  18. | 'Access-Control-Allow-Origin'
  19. | 'Access-Control-Expose-Headers'
  20. | 'Access-Control-Max-Age'
  21. | 'Access-Control-Request-Headers'
  22. | 'Access-Control-Request-Method'
  23. | 'Age'
  24. | 'Allow'
  25. | 'Alt-Svc'
  26. | 'Alt-Used'
  27. | 'Authorization'
  28. | 'Cache-Control'
  29. | 'Clear-Site-Data'
  30. | 'Connection'
  31. | 'Content-Disposition'
  32. | 'Content-Encoding'
  33. | 'Content-Language'
  34. | 'Content-Length'
  35. | 'Content-Location'
  36. | 'Content-Range'
  37. | 'Content-Security-Policy'
  38. | 'Content-Security-Policy-Report-Only'
  39. | 'Content-Type'
  40. | 'Cookie'
  41. | 'Cross-Origin-Embedder-Policy'
  42. | 'Cross-Origin-Opener-Policy'
  43. | 'Cross-Origin-Resource-Policy'
  44. | 'Date'
  45. | 'Device-Memory'
  46. | 'ETag'
  47. | 'Expect'
  48. | 'Expect-CT'
  49. | 'Expires'
  50. | 'Forwarded'
  51. | 'From'
  52. | 'Host'
  53. | 'If-Match'
  54. | 'If-Modified-Since'
  55. | 'If-None-Match'
  56. | 'If-Range'
  57. | 'If-Unmodified-Since'
  58. | 'Keep-Alive'
  59. | 'Last-Modified'
  60. | 'Link'
  61. | 'Location'
  62. | 'Max-Forwards'
  63. | 'Origin'
  64. | 'Permissions-Policy'
  65. | 'Priority'
  66. | 'Proxy-Authenticate'
  67. | 'Proxy-Authorization'
  68. | 'Range'
  69. | 'Referer'
  70. | 'Referrer-Policy'
  71. | 'Retry-After'
  72. | 'Sec-Fetch-Dest'
  73. | 'Sec-Fetch-Mode'
  74. | 'Sec-Fetch-Site'
  75. | 'Sec-Fetch-User'
  76. | 'Sec-Purpose'
  77. | 'Sec-WebSocket-Accept'
  78. | 'Server'
  79. | 'Server-Timing'
  80. | 'Service-Worker-Navigation-Preload'
  81. | 'Set-Cookie'
  82. | 'SourceMap'
  83. | 'Strict-Transport-Security'
  84. | 'TE'
  85. | 'Timing-Allow-Origin'
  86. | 'Trailer'
  87. | 'Transfer-Encoding'
  88. | 'Upgrade'
  89. | 'Upgrade-Insecure-Requests'
  90. | 'User-Agent'
  91. | 'Vary'
  92. | 'Via'
  93. | 'WWW-Authenticate'
  94. | 'X-Content-Type-Options'
  95. | 'X-Frame-Options'
  96. >
  97. type IANARegisteredMimeType = Autocomplete<
  98. | 'audio/aac'
  99. | 'video/x-msvideo'
  100. | 'image/avif'
  101. | 'video/av1'
  102. | 'application/octet-stream'
  103. | 'image/bmp'
  104. | 'text/css'
  105. | 'text/csv'
  106. | 'application/vnd.ms-fontobject'
  107. | 'application/epub+zip'
  108. | 'image/gif'
  109. | 'application/gzip'
  110. | 'text/html'
  111. | 'image/x-icon'
  112. | 'text/calendar'
  113. | 'image/jpeg'
  114. | 'text/javascript'
  115. | 'application/json'
  116. | 'application/ld+json'
  117. | 'audio/x-midi'
  118. | 'audio/mpeg'
  119. | 'video/mp4'
  120. | 'video/mpeg'
  121. | 'audio/ogg'
  122. | 'video/ogg'
  123. | 'application/ogg'
  124. | 'audio/opus'
  125. | 'font/otf'
  126. | 'application/pdf'
  127. | 'image/png'
  128. | 'application/rtf'
  129. | 'image/svg+xml'
  130. | 'image/tiff'
  131. | 'video/mp2t'
  132. | 'font/ttf'
  133. | 'text/plain'
  134. | 'application/wasm'
  135. | 'video/webm'
  136. | 'audio/webm'
  137. | 'image/webp'
  138. | 'font/woff'
  139. | 'font/woff2'
  140. | 'application/xhtml+xml'
  141. | 'application/xml'
  142. | 'application/zip'
  143. | 'video/3gpp'
  144. | 'video/3gpp2'
  145. | 'model/gltf+json'
  146. | 'model/gltf-binary'
  147. >
  148. type KnownHeaderValues = {
  149. 'content-type': IANARegisteredMimeType
  150. }
  151. export type HeaderRecord = {
  152. [K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues
  153. ? KnownHeaderValues[Lowercase<K>]
  154. : string
  155. }