|
1 | 1 | type http = [ | `Http]; |
2 | 2 |
|
| 3 | +module Headers = { |
| 4 | + type t = pri { |
| 5 | + accept: option(string), |
| 6 | + [@bs.as "accept-language"] acceptLanguage: option(string), |
| 7 | + [@bs.as "accept-patch"] acceptPatch: option(string), |
| 8 | + [@bs.as "accept-ranges"] acceptRanges: option(string), |
| 9 | + [@bs.as "access-control-allow-credentials"] accessControlAllowCredentials: option(string), |
| 10 | + [@bs.as "access-control-allow-headers"] accessControlAllowHeaders: option(string), |
| 11 | + [@bs.as "access-control-allow-methods"] accessControlAllowMethods: (string), |
| 12 | + [@bs.as "access-control-allow-origin"] accessControlAllowOrigin: option(string), |
| 13 | + [@bs.as "access-control-expose-headers"] accessControlExposeHeaders: option(string), |
| 14 | + [@bs.as "access-control-max-age"] accessControlMaxAge: option(string), |
| 15 | + age: option(string), |
| 16 | + allow: option(string), |
| 17 | + [@bs.as "alt-svc"] altSvc: option(string), |
| 18 | + authorization: option(string), |
| 19 | + [@bs.as "cache-control"] cacheControl: option(string), |
| 20 | + connection: option(string), |
| 21 | + [@bs.as "content-disposition"] contentDisposition: option(string), |
| 22 | + [@bs.as "content-encoding"] contentEncoding: option(string), |
| 23 | + [@bs.as "content-language"] contentLanguage: option(string), |
| 24 | + [@bs.as "content-length"] contentLenth: option(string), |
| 25 | + [@bs.as "content-location"] contentLocation: option(string), |
| 26 | + [@bs.as "content-range"] contentRange: option(string), |
| 27 | + [@bs.as "content-type"] contentType: option(string), |
| 28 | + cookie: option(string), |
| 29 | + date: option(string), |
| 30 | + expect: option(string), |
| 31 | + expires: option(string), |
| 32 | + forwarded: option(string), |
| 33 | + from: option(string), |
| 34 | + host: option(string), |
| 35 | + [@bs.as "if-match"] ifMatch: option(string), |
| 36 | + [@bs.as "if-modified-since"] ifModifiedSince: option(string), |
| 37 | + [@bs.as "if-none-match"] ifNoneMatch: option(string), |
| 38 | + [@bs.as "if-unmodified-since"] ifUnmodifiedSince: option(string), |
| 39 | + [@bs.as "last-modified"] lastModified: option(string), |
| 40 | + location: option(string), |
| 41 | + pragma: option(string), |
| 42 | + [@bs.as "proxy-authenticate"] proxyAuthenticate: option(string), |
| 43 | + [@bs.as "proxy-authorization"] proxyAuthorization: option(string), |
| 44 | + [@bs.as "public-key-pins"] publicKeyPins: option(string), |
| 45 | + range: option(string), |
| 46 | + referer: option(string), |
| 47 | + [@bs.as "retry-after"] retryAfter: option(string), |
| 48 | + [@bs.as "set-cookie"] setCookie: option(array(string)), |
| 49 | + [@bs.as "strict-transport-security"] strictTransportPolicy: option(string), |
| 50 | + tk: option(string), |
| 51 | + trailer: option(string), |
| 52 | + [@bs.as "transfer-encoding"] transferEncoding: option(string), |
| 53 | + upgrade: option(string), |
| 54 | + [@bs.as "user-agent"] userAgent: option(string), |
| 55 | + vary: option(string), |
| 56 | + via: option(string), |
| 57 | + warning: option(string), |
| 58 | + [@bs.as "www-authenticate"] wwwAuthenticate: option(string), |
| 59 | + }; |
| 60 | +}; |
| 61 | + |
3 | 62 | module IncomingMessage = { |
4 | 63 | type kind = [ Stream.readable | `IncomingMessage]; |
5 | 64 | type subtype('w, 'r, 'a) = Stream.subtype('w, 'r, [> kind] as 'a); |
@@ -69,7 +128,7 @@ module IncomingMessage = { |
69 | 128 | [@bs.get] external url: subtype('w, 'r, 'a) => string = "url"; |
70 | 129 | [@bs.get] external port: subtype('w, 'r, 'a) => int = "port"; |
71 | 130 | [@bs.get] |
72 | | - external headers: subtype('w, 'r, 'a) => Js.Dict.t(string) = "headers"; |
| 131 | + external headers: subtype('w, 'r, 'a) => Headers.t = "headers"; |
73 | 132 | [@bs.get] |
74 | 133 | external rawHeaders: subtype('w, 'r, 'a) => array(string) = "rawHeaders"; |
75 | 134 | [@bs.get] |
@@ -109,15 +168,14 @@ module ClientRequest = { |
109 | 168 | type subtype('w, 'r, 'a) = Stream.subtype('w, 'r, [> kind] as 'a); |
110 | 169 | type supertype('w, 'r, 'a) = Stream.subtype('w, 'r, [< kind] as 'a); |
111 | 170 | type t = subtype(Buffer.t, Buffer.t, [ kind]); |
112 | | - type information('a) = { |
113 | | - . |
114 | | - "httpVersion": string, |
115 | | - "httpVersionMajor": int, |
116 | | - "httpVersionMinor": int, |
117 | | - "statusCode": int, |
118 | | - "statusMessage": string, |
119 | | - "headers": Js.t({..} as 'a), |
120 | | - "rawHeaders": array(string), |
| 171 | + type information = { |
| 172 | + httpVersion: string, |
| 173 | + httpVersionMajor: int, |
| 174 | + httpVersionMinor: int, |
| 175 | + statusCode: int, |
| 176 | + statusMessage: string, |
| 177 | + headers: Headers.t, |
| 178 | + rawHeaders: array(string), |
121 | 179 | }; |
122 | 180 | module Events = { |
123 | 181 | include Stream.Duplex.Events; |
@@ -158,7 +216,7 @@ module ClientRequest = { |
158 | 216 | ( |
159 | 217 | subtype('w, 'r, 'a), |
160 | 218 | [@bs.as "information"] _, |
161 | | - [@bs.uncurry] (information('b) => unit) |
| 219 | + [@bs.uncurry] (information => unit) |
162 | 220 | ) => |
163 | 221 | subtype('w, 'r, 'a) = |
164 | 222 | "on"; |
@@ -239,7 +297,7 @@ module ClientRequest = { |
239 | 297 | ( |
240 | 298 | subtype('w, 'r, 'a), |
241 | 299 | [@bs.as "information"] _, |
242 | | - [@bs.uncurry] (information('b) => unit) |
| 300 | + [@bs.uncurry] (information => unit) |
243 | 301 | ) => |
244 | 302 | subtype('w, 'r, 'a) = |
245 | 303 | "off"; |
@@ -320,7 +378,7 @@ module ClientRequest = { |
320 | 378 | ( |
321 | 379 | subtype('w, 'r, 'a), |
322 | 380 | [@bs.as "information"] _, |
323 | | - [@bs.uncurry] (information('b) => unit) |
| 381 | + [@bs.uncurry] (information => unit) |
324 | 382 | ) => |
325 | 383 | subtype('w, 'r, 'a) = |
326 | 384 | "once"; |
@@ -521,7 +579,7 @@ module ServerResponse = { |
521 | 579 | external getHeaderNames: subtype('w, 'r, 'a) => array(string) = |
522 | 580 | "getHeaderNames"; |
523 | 581 | [@bs.send] |
524 | | - external getHeaders: subtype('w, 'r, 'a) => Js.t({..}) = "getHeaders"; |
| 582 | + external getHeaders: subtype('w, 'r, 'a) => Headers.t = "getHeaders"; |
525 | 583 | [@bs.send] |
526 | 584 | external hasHeader: (subtype('w, 'r, 'a), string) => bool = "hasHeader"; |
527 | 585 | [@bs.get] |
@@ -852,7 +910,7 @@ external requestOptions: |
852 | 910 | ~createConnection: unit => Net.TcpSocket.t=?, |
853 | 911 | ~defaultPort: int=?, |
854 | 912 | ~family: int=?, |
855 | | - ~headers: Js.t({..})=?, |
| 913 | + ~headers: Headers.t=?, |
856 | 914 | ~host: string=?, |
857 | 915 | ~hostName: string=?, |
858 | 916 | ~localAddress: string=?, |
|
0 commit comments