@jayfong/x-server 1.18.0 → 1.20.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.20.1](https://github.com/jfWorks/x-server/compare/v1.20.0...v1.20.1) (2022-04-27)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * res == null ? ({} as any) : res ([ea0c531](https://github.com/jfWorks/x-server/commit/ea0c531524636cf9a92e43646fb37bd57b6148d7))
11
+
12
+ ## [1.20.0](https://github.com/jfWorks/x-server/compare/v1.19.0...v1.20.0) (2022-04-27)
13
+
14
+
15
+ ### Features
16
+
17
+ * add responseContentType ([dcd9841](https://github.com/jfWorks/x-server/commit/dcd9841e7940d0bc4dfd55faa69deedd1463aee0))
18
+
19
+ ## [1.19.0](https://github.com/jfWorks/x-server/compare/v1.18.0...v1.19.0) (2022-04-27)
20
+
21
+
22
+ ### Features
23
+
24
+ * http_header ([b4cc67b](https://github.com/jfWorks/x-server/commit/b4cc67b88f523e9bb0535e9edd2ce6e27d5ff209))
25
+
5
26
  ## [1.18.0](https://github.com/jfWorks/x-server/compare/v1.17.0...v1.18.0) (2022-04-27)
6
27
 
7
28
 
@@ -43,13 +43,18 @@ class Handler {
43
43
  }
44
44
  }
45
45
 
46
- let res = await this.options.handle(data, ctx); // 打包返回数据
46
+ let res = await this.options.handle(data, ctx); // 设置响应的 Content-Type 头
47
+
48
+ if (this.options.responseContentType) {
49
+ ctx.setHeader('Content-Type', this.options.responseContentType);
50
+ } // 打包返回数据
51
+
47
52
 
48
53
  if (this.options.responseDataPack) {
49
54
  res = _vtils.DataPacker.packAsRawType(res);
50
55
  }
51
56
 
52
- return res;
57
+ return res == null ? {} : res;
53
58
  };
54
59
 
55
60
  this.handleWs = async (data, ctx) => {
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.HttpResponseHeader = exports.HttpRequestHeader = void 0;
5
+ // https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
6
+
7
+ /**
8
+ [...$0.querySelectorAll('tr')].map(v => v.querySelector('td:nth-child(1)').innerText.trim().split(',').map(name => name.replace(/\[.*?\]/g, '').trim()).map((name) => ({
9
+ name: name,
10
+ description: v.querySelector('td:nth-child(2)').innerText.replace(/\[.*?\]/g, '').trim(),
11
+ example: v.querySelector('td:nth-child(3)').innerText.trim(),
12
+ pascalName: name.replace(/\-/g, '_').toUpperCase()
13
+ }))).flat().map(item => `
14
+ ${'/'}**
15
+ * ${item.description}
16
+ *
17
+ * @example
18
+ * ${item.example}
19
+ *${'/'}
20
+ ${item.pascalName} = '${item.name}',
21
+ `).join('\n\n')
22
+ */
23
+ let HttpRequestHeader;
24
+ exports.HttpRequestHeader = HttpRequestHeader;
25
+
26
+ (function (HttpRequestHeader) {
27
+ HttpRequestHeader["A_IM"] = "A-IM";
28
+ HttpRequestHeader["ACCEPT"] = "Accept";
29
+ HttpRequestHeader["ACCEPT_CHARSET"] = "Accept-Charset";
30
+ HttpRequestHeader["ACCEPT_DATETIME"] = "Accept-Datetime";
31
+ HttpRequestHeader["ACCEPT_ENCODING"] = "Accept-Encoding";
32
+ HttpRequestHeader["ACCEPT_LANGUAGE"] = "Accept-Language";
33
+ HttpRequestHeader["ACCESS_CONTROL_REQUEST_METHOD"] = "Access-Control-Request-Method";
34
+ HttpRequestHeader["ACCESS_CONTROL_REQUEST_HEADERS"] = "Access-Control-Request-Headers";
35
+ HttpRequestHeader["AUTHORIZATION"] = "Authorization";
36
+ HttpRequestHeader["CACHE_CONTROL"] = "Cache-Control";
37
+ HttpRequestHeader["CONNECTION"] = "Connection";
38
+ HttpRequestHeader["CONTENT_ENCODING"] = "Content-Encoding";
39
+ HttpRequestHeader["CONTENT_LENGTH"] = "Content-Length";
40
+ HttpRequestHeader["CONTENT_MD5"] = "Content-MD5";
41
+ HttpRequestHeader["CONTENT_TYPE"] = "Content-Type";
42
+ HttpRequestHeader["COOKIE"] = "Cookie";
43
+ HttpRequestHeader["DATE"] = "Date";
44
+ HttpRequestHeader["EXPECT"] = "Expect";
45
+ HttpRequestHeader["FORWARDED"] = "Forwarded";
46
+ HttpRequestHeader["FROM"] = "From";
47
+ HttpRequestHeader["HOST"] = "Host";
48
+ HttpRequestHeader["HTTP2_SETTINGS"] = "HTTP2-Settings";
49
+ HttpRequestHeader["IF_MATCH"] = "If-Match";
50
+ HttpRequestHeader["IF_MODIFIED_SINCE"] = "If-Modified-Since";
51
+ HttpRequestHeader["IF_NONE_MATCH"] = "If-None-Match";
52
+ HttpRequestHeader["IF_RANGE"] = "If-Range";
53
+ HttpRequestHeader["IF_UNMODIFIED_SINCE"] = "If-Unmodified-Since";
54
+ HttpRequestHeader["MAX_FORWARDS"] = "Max-Forwards";
55
+ HttpRequestHeader["ORIGIN"] = "Origin";
56
+ HttpRequestHeader["PRAGMA"] = "Pragma";
57
+ HttpRequestHeader["PROXY_AUTHORIZATION"] = "Proxy-Authorization";
58
+ HttpRequestHeader["RANGE"] = "Range";
59
+ HttpRequestHeader["REFERER"] = "Referer";
60
+ HttpRequestHeader["TE"] = "TE";
61
+ HttpRequestHeader["TRAILER"] = "Trailer";
62
+ HttpRequestHeader["TRANSFER_ENCODING"] = "Transfer-Encoding";
63
+ HttpRequestHeader["USER_AGENT"] = "User-Agent";
64
+ HttpRequestHeader["UPGRADE"] = "Upgrade";
65
+ HttpRequestHeader["VIA"] = "Via";
66
+ HttpRequestHeader["WARNING"] = "Warning";
67
+ HttpRequestHeader["UPGRADE_INSECURE_REQUESTS"] = "Upgrade-Insecure-Requests";
68
+ HttpRequestHeader["X_REQUESTED_WITH"] = "X-Requested-With";
69
+ HttpRequestHeader["DNT"] = "DNT";
70
+ HttpRequestHeader["X_FORWARDED_FOR"] = "X-Forwarded-For";
71
+ HttpRequestHeader["X_FORWARDED_HOST"] = "X-Forwarded-Host";
72
+ HttpRequestHeader["X_FORWARDED_PROTO"] = "X-Forwarded-Proto";
73
+ HttpRequestHeader["FRONT_END_HTTPS"] = "Front-End-Https";
74
+ HttpRequestHeader["X_HTTP_METHOD_OVERRIDE"] = "X-Http-Method-Override";
75
+ HttpRequestHeader["X_ATT_DEVICEID"] = "X-ATT-DeviceId";
76
+ HttpRequestHeader["X_WAP_PROFILE"] = "X-Wap-Profile";
77
+ HttpRequestHeader["PROXY_CONNECTION"] = "Proxy-Connection";
78
+ HttpRequestHeader["X_UIDH"] = "X-UIDH";
79
+ HttpRequestHeader["X_CSRF_TOKEN"] = "X-Csrf-Token";
80
+ HttpRequestHeader["X_REQUEST_ID"] = "X-Request-ID";
81
+ HttpRequestHeader["X_CORRELATION_ID"] = "X-Correlation-ID";
82
+ HttpRequestHeader["SAVE_DATA"] = "Save-Data";
83
+ })(HttpRequestHeader || (exports.HttpRequestHeader = HttpRequestHeader = {}));
84
+
85
+ let HttpResponseHeader;
86
+ exports.HttpResponseHeader = HttpResponseHeader;
87
+
88
+ (function (HttpResponseHeader) {
89
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_ORIGIN"] = "Access-Control-Allow-Origin";
90
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_CREDENTIALS"] = "Access-Control-Allow-Credentials";
91
+ HttpResponseHeader["ACCESS_CONTROL_EXPOSE_HEADERS"] = "Access-Control-Expose-Headers";
92
+ HttpResponseHeader["ACCESS_CONTROL_MAX_AGE"] = "Access-Control-Max-Age";
93
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_METHODS"] = "Access-Control-Allow-Methods";
94
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_HEADERS"] = "Access-Control-Allow-Headers";
95
+ HttpResponseHeader["ACCEPT_PATCH"] = "Accept-Patch";
96
+ HttpResponseHeader["ACCEPT_RANGES"] = "Accept-Ranges";
97
+ HttpResponseHeader["AGE"] = "Age";
98
+ HttpResponseHeader["ALLOW"] = "Allow";
99
+ HttpResponseHeader["ALT_SVC"] = "Alt-Svc";
100
+ HttpResponseHeader["CACHE_CONTROL"] = "Cache-Control";
101
+ HttpResponseHeader["CONNECTION"] = "Connection";
102
+ HttpResponseHeader["CONTENT_DISPOSITION"] = "Content-Disposition";
103
+ HttpResponseHeader["CONTENT_ENCODING"] = "Content-Encoding";
104
+ HttpResponseHeader["CONTENT_LANGUAGE"] = "Content-Language";
105
+ HttpResponseHeader["CONTENT_LENGTH"] = "Content-Length";
106
+ HttpResponseHeader["CONTENT_LOCATION"] = "Content-Location";
107
+ HttpResponseHeader["CONTENT_MD5"] = "Content-MD5";
108
+ HttpResponseHeader["CONTENT_RANGE"] = "Content-Range";
109
+ HttpResponseHeader["CONTENT_TYPE"] = "Content-Type";
110
+ HttpResponseHeader["DATE"] = "Date";
111
+ HttpResponseHeader["DELTA_BASE"] = "Delta-Base";
112
+ HttpResponseHeader["ETAG"] = "ETag";
113
+ HttpResponseHeader["EXPIRES"] = "Expires";
114
+ HttpResponseHeader["IM"] = "IM";
115
+ HttpResponseHeader["LAST_MODIFIED"] = "Last-Modified";
116
+ HttpResponseHeader["LINK"] = "Link";
117
+ HttpResponseHeader["LOCATION"] = "Location";
118
+ HttpResponseHeader["P3P"] = "P3P";
119
+ HttpResponseHeader["PRAGMA"] = "Pragma";
120
+ HttpResponseHeader["PROXY_AUTHENTICATE"] = "Proxy-Authenticate";
121
+ HttpResponseHeader["PUBLIC_KEY_PINS"] = "Public-Key-Pins";
122
+ HttpResponseHeader["RETRY_AFTER"] = "Retry-After";
123
+ HttpResponseHeader["SERVER"] = "Server";
124
+ HttpResponseHeader["SET_COOKIE"] = "Set-Cookie";
125
+ HttpResponseHeader["STRICT_TRANSPORT_SECURITY"] = "Strict-Transport-Security";
126
+ HttpResponseHeader["TRAILER"] = "Trailer";
127
+ HttpResponseHeader["TRANSFER_ENCODING"] = "Transfer-Encoding";
128
+ HttpResponseHeader["TK"] = "Tk";
129
+ HttpResponseHeader["UPGRADE"] = "Upgrade";
130
+ HttpResponseHeader["VARY"] = "Vary";
131
+ HttpResponseHeader["VIA"] = "Via";
132
+ HttpResponseHeader["WARNING"] = "Warning";
133
+ HttpResponseHeader["WWW_AUTHENTICATE"] = "WWW-Authenticate";
134
+ HttpResponseHeader["X_FRAME_OPTIONS"] = "X-Frame-Options";
135
+ HttpResponseHeader["CONTENT_SECURITY_POLICY"] = "Content-Security-Policy";
136
+ HttpResponseHeader["X_CONTENT_SECURITY_POLICY"] = "X-Content-Security-Policy";
137
+ HttpResponseHeader["X_WEBKIT_CSP"] = "X-WebKit-CSP";
138
+ HttpResponseHeader["REFRESH"] = "Refresh";
139
+ HttpResponseHeader["STATUS"] = "Status";
140
+ HttpResponseHeader["TIMING_ALLOW_ORIGIN"] = "Timing-Allow-Origin";
141
+ HttpResponseHeader["X_CONTENT_DURATION"] = "X-Content-Duration";
142
+ HttpResponseHeader["X_CONTENT_TYPE_OPTIONS"] = "X-Content-Type-Options";
143
+ HttpResponseHeader["X_POWERED_BY"] = "X-Powered-By";
144
+ HttpResponseHeader["X_REQUEST_ID"] = "X-Request-ID";
145
+ HttpResponseHeader["X_CORRELATION_ID"] = "X-Correlation-ID";
146
+ HttpResponseHeader["X_UA_COMPATIBLE"] = "X-UA-Compatible";
147
+ HttpResponseHeader["X_XSS_PROTECTION"] = "X-XSS-Protection";
148
+ })(HttpResponseHeader || (exports.HttpResponseHeader = HttpResponseHeader = {}));
@@ -102,7 +102,7 @@ class Server {
102
102
  await item.handler.handle(undefined, {
103
103
  url: url,
104
104
  headers: req.headers,
105
- setHeader: res.header,
105
+ setHeader: (k, v) => res.header(k, v),
106
106
  redirect: undefined,
107
107
  ws: req
108
108
  });
@@ -130,7 +130,7 @@ class Server {
130
130
  }, {
131
131
  url: url,
132
132
  headers: req.headers,
133
- setHeader: res.header,
133
+ setHeader: (k, v) => res.header(k, v),
134
134
  redirect: url => res.redirect(url),
135
135
  ws: undefined
136
136
  });
package/lib/_cjs/index.js CHANGED
@@ -58,6 +58,14 @@ Object.keys(_http_error).forEach(function (key) {
58
58
  exports[key] = _http_error[key];
59
59
  });
60
60
 
61
+ var _http_header = require("./core/http_header");
62
+
63
+ Object.keys(_http_header).forEach(function (key) {
64
+ if (key === "default" || key === "__esModule") return;
65
+ if (key in exports && exports[key] === _http_header[key]) return;
66
+ exports[key] = _http_header[key];
67
+ });
68
+
61
69
  var _http_method = require("./core/http_method");
62
70
 
63
71
  Object.keys(_http_method).forEach(function (key) {
@@ -34,13 +34,18 @@ export class Handler {
34
34
  }
35
35
  }
36
36
 
37
- let res = await this.options.handle(data, ctx); // 打包返回数据
37
+ let res = await this.options.handle(data, ctx); // 设置响应的 Content-Type 头
38
+
39
+ if (this.options.responseContentType) {
40
+ ctx.setHeader('Content-Type', this.options.responseContentType);
41
+ } // 打包返回数据
42
+
38
43
 
39
44
  if (this.options.responseDataPack) {
40
45
  res = DataPacker.packAsRawType(res);
41
46
  }
42
47
 
43
- return res;
48
+ return res == null ? {} : res;
44
49
  };
45
50
 
46
51
  this.handleWs = async (data, ctx) => {
@@ -0,0 +1,856 @@
1
+ /**
2
+ [...$0.querySelectorAll('tr')].map(v => v.querySelector('td:nth-child(1)').innerText.trim().split(',').map(name => name.replace(/\[.*?\]/g, '').trim()).map((name) => ({
3
+ name: name,
4
+ description: v.querySelector('td:nth-child(2)').innerText.replace(/\[.*?\]/g, '').trim(),
5
+ example: v.querySelector('td:nth-child(3)').innerText.trim(),
6
+ pascalName: name.replace(/\-/g, '_').toUpperCase()
7
+ }))).flat().map(item => `
8
+ ${'/'}**
9
+ * ${item.description}
10
+ *
11
+ * @example
12
+ * ${item.example}
13
+ *${'/'}
14
+ ${item.pascalName} = '${item.name}',
15
+ `).join('\n\n')
16
+ */
17
+ export declare enum HttpRequestHeader {
18
+ /**
19
+ * Acceptable instance-manipulations for the request.
20
+ *
21
+ * @example
22
+ * A-IM: feed
23
+ */
24
+ A_IM = "A-IM",
25
+ /**
26
+ * Media type(s) that is/are acceptable for the response. See Content negotiation.
27
+ *
28
+ * @example
29
+ * Accept: text/html
30
+ */
31
+ ACCEPT = "Accept",
32
+ /**
33
+ * Character sets that are acceptable.
34
+ *
35
+ * @example
36
+ * Accept-Charset: utf-8
37
+ */
38
+ ACCEPT_CHARSET = "Accept-Charset",
39
+ /**
40
+ * Acceptable version in time.
41
+ *
42
+ * @example
43
+ * Accept-Datetime: Thu, 31 May 2007 20:35:00 GMT
44
+ */
45
+ ACCEPT_DATETIME = "Accept-Datetime",
46
+ /**
47
+ * List of acceptable encodings. See HTTP compression.
48
+ *
49
+ * @example
50
+ * Accept-Encoding: gzip, deflate
51
+ */
52
+ ACCEPT_ENCODING = "Accept-Encoding",
53
+ /**
54
+ * List of acceptable human languages for response. See Content negotiation.
55
+ *
56
+ * @example
57
+ * Accept-Language: en-US
58
+ */
59
+ ACCEPT_LANGUAGE = "Accept-Language",
60
+ /**
61
+ * Initiates a request for cross-origin resource sharing with Origin (below).
62
+ *
63
+ * @example
64
+ * Access-Control-Request-Method: GET
65
+ */
66
+ ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method",
67
+ /**
68
+ * Initiates a request for cross-origin resource sharing with Origin (below).
69
+ *
70
+ * @example
71
+ * Access-Control-Request-Method: GET
72
+ */
73
+ ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers",
74
+ /**
75
+ * Authentication credentials for HTTP authentication.
76
+ *
77
+ * @example
78
+ * Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
79
+ */
80
+ AUTHORIZATION = "Authorization",
81
+ /**
82
+ * Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain.
83
+ *
84
+ * @example
85
+ * Cache-Control: no-cache
86
+ */
87
+ CACHE_CONTROL = "Cache-Control",
88
+ /**
89
+ * Control options for the current connection and list of hop-by-hop request fields.
90
+ Must not be used with HTTP/2.
91
+ *
92
+ * @example
93
+ * Connection: keep-alive
94
+ Connection: Upgrade
95
+ */
96
+ CONNECTION = "Connection",
97
+ /**
98
+ * The type of encoding used on the data. See HTTP compression.
99
+ *
100
+ * @example
101
+ * Content-Encoding: gzip
102
+ */
103
+ CONTENT_ENCODING = "Content-Encoding",
104
+ /**
105
+ * The length of the request body in octets (8-bit bytes).
106
+ *
107
+ * @example
108
+ * Content-Length: 348
109
+ */
110
+ CONTENT_LENGTH = "Content-Length",
111
+ /**
112
+ * A Base64-encoded binary MD5 sum of the content of the request body.
113
+ *
114
+ * @example
115
+ * Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==
116
+ */
117
+ CONTENT_MD5 = "Content-MD5",
118
+ /**
119
+ * The Media type of the body of the request (used with POST and PUT requests).
120
+ *
121
+ * @example
122
+ * Content-Type: application/x-www-form-urlencoded
123
+ */
124
+ CONTENT_TYPE = "Content-Type",
125
+ /**
126
+ * An HTTP cookie previously sent by the server with Set-Cookie (below).
127
+ *
128
+ * @example
129
+ * Cookie: $Version=1; Skin=new;
130
+ */
131
+ COOKIE = "Cookie",
132
+ /**
133
+ * The date and time at which the message was originated (in "HTTP-date" format as defined by RFC 7231 Date/Time Formats).
134
+ *
135
+ * @example
136
+ * Date: Tue, 15 Nov 1994 08:12:31 GMT
137
+ */
138
+ DATE = "Date",
139
+ /**
140
+ * Indicates that particular server behaviors are required by the client.
141
+ *
142
+ * @example
143
+ * Expect: 100-continue
144
+ */
145
+ EXPECT = "Expect",
146
+ /**
147
+ * Disclose original information of a client connecting to a web server through an HTTP proxy.
148
+ *
149
+ * @example
150
+ * Forwarded: for=192.0.2.60;proto=http;by=203.0.113.43 Forwarded: for=192.0.2.43, for=198.51.100.17
151
+ */
152
+ FORWARDED = "Forwarded",
153
+ /**
154
+ * The email address of the user making the request.
155
+ *
156
+ * @example
157
+ * From: user@example.com
158
+ */
159
+ FROM = "From",
160
+ /**
161
+ * The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The port number may be omitted if the port is the standard port for the service requested.
162
+ Mandatory since HTTP/1.1. If the request is generated directly in HTTP/2, it should not be used.
163
+ *
164
+ * @example
165
+ * Host: en.wikipedia.org:8080
166
+ Host: en.wikipedia.org
167
+ */
168
+ HOST = "Host",
169
+ /**
170
+ * A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly one HTTP2-Setting header field. The HTTP2-Settings header field is a connection-specific header field that includes parameters that govern the HTTP/2 connection, provided in anticipation of the server accepting the request to upgrade.
171
+ *
172
+ * @example
173
+ * HTTP2-Settings: token64
174
+ */
175
+ HTTP2_SETTINGS = "HTTP2-Settings",
176
+ /**
177
+ * Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for methods like PUT to only update a resource if it has not been modified since the user last updated it.
178
+ *
179
+ * @example
180
+ * If-Match: "737060cd8c284d8af7ad3082f209582d"
181
+ */
182
+ IF_MATCH = "If-Match",
183
+ /**
184
+ * Allows a 304 Not Modified to be returned if content is unchanged.
185
+ *
186
+ * @example
187
+ * If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
188
+ */
189
+ IF_MODIFIED_SINCE = "If-Modified-Since",
190
+ /**
191
+ * Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag.
192
+ *
193
+ * @example
194
+ * If-None-Match: "737060cd8c284d8af7ad3082f209582d"
195
+ */
196
+ IF_NONE_MATCH = "If-None-Match",
197
+ /**
198
+ * If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity.
199
+ *
200
+ * @example
201
+ * If-Range: "737060cd8c284d8af7ad3082f209582d"
202
+ */
203
+ IF_RANGE = "If-Range",
204
+ /**
205
+ * Only send the response if the entity has not been modified since a specific time.
206
+ *
207
+ * @example
208
+ * If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
209
+ */
210
+ IF_UNMODIFIED_SINCE = "If-Unmodified-Since",
211
+ /**
212
+ * Limit the number of times the message can be forwarded through proxies or gateways.
213
+ *
214
+ * @example
215
+ * Max-Forwards: 10
216
+ */
217
+ MAX_FORWARDS = "Max-Forwards",
218
+ /**
219
+ * Initiates a request for cross-origin resource sharing (asks server for Access-Control-* response fields).
220
+ *
221
+ * @example
222
+ * Origin: http://www.example-social-network.com
223
+ */
224
+ ORIGIN = "Origin",
225
+ /**
226
+ * Implementation-specific fields that may have various effects anywhere along the request-response chain.
227
+ *
228
+ * @example
229
+ * Pragma: no-cache
230
+ */
231
+ PRAGMA = "Pragma",
232
+ /**
233
+ * Authorization credentials for connecting to a proxy.
234
+ *
235
+ * @example
236
+ * Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
237
+ */
238
+ PROXY_AUTHORIZATION = "Proxy-Authorization",
239
+ /**
240
+ * Request only part of an entity. Bytes are numbered from 0. See Byte serving.
241
+ *
242
+ * @example
243
+ * Range: bytes=500-999
244
+ */
245
+ RANGE = "Range",
246
+ /**
247
+ * This is the address of the previous web page from which a link to the currently requested page was followed. (The word "referrer" has been misspelled in the RFC as well as in most implementations to the point that it has become standard usage and is considered correct terminology)
248
+ *
249
+ * @example
250
+ * Referer: http://en.wikipedia.org/wiki/Main_Page
251
+ */
252
+ REFERER = "Referer",
253
+ /**
254
+ * The transfer encodings the user agent is willing to accept: the same values as for the response header field Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the server it expects to receive additional fields in the trailer after the last, zero-sized, chunk.
255
+ Only trailers is supported in HTTP/2.
256
+ *
257
+ * @example
258
+ * TE: trailers, deflate
259
+ */
260
+ TE = "TE",
261
+ /**
262
+ * The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding.
263
+ *
264
+ * @example
265
+ * Trailer: Max-Forwards
266
+ */
267
+ TRAILER = "Trailer",
268
+ /**
269
+ * The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.
270
+ Must not be used with HTTP/2.
271
+ *
272
+ * @example
273
+ * Transfer-Encoding: chunked
274
+ */
275
+ TRANSFER_ENCODING = "Transfer-Encoding",
276
+ /**
277
+ * The user agent string of the user agent.
278
+ *
279
+ * @example
280
+ * User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0
281
+ */
282
+ USER_AGENT = "User-Agent",
283
+ /**
284
+ * Ask the server to upgrade to another protocol.
285
+ Must not be used in HTTP/2.
286
+ *
287
+ * @example
288
+ * Upgrade: h2c, HTTPS/1.3, IRC/6.9, RTA/x11, websocket
289
+ */
290
+ UPGRADE = "Upgrade",
291
+ /**
292
+ * Informs the server of proxies through which the request was sent.
293
+ *
294
+ * @example
295
+ * Via: 1.0 fred, 1.1 example.com (Apache/1.1)
296
+ */
297
+ VIA = "Via",
298
+ /**
299
+ * A general warning about possible problems with the entity body.
300
+ *
301
+ * @example
302
+ * Warning: 199 Miscellaneous warning
303
+ */
304
+ WARNING = "Warning",
305
+ /**
306
+ * Tells a server which (presumably in the middle of a HTTP -> HTTPS migration) hosts mixed content that the client would prefer redirection to HTTPS and can handle Content-Security-Policy: upgrade-insecure-requests
307
+ Must not be used with HTTP/2
308
+ *
309
+ * @example
310
+ * Upgrade-Insecure-Requests: 1
311
+ */
312
+ UPGRADE_INSECURE_REQUESTS = "Upgrade-Insecure-Requests",
313
+ /**
314
+ * Mainly used to identify Ajax requests (most JavaScript frameworks send this field with value of XMLHttpRequest); also identifies Android apps using WebView
315
+ *
316
+ * @example
317
+ * X-Requested-With: XMLHttpRequest
318
+ */
319
+ X_REQUESTED_WITH = "X-Requested-With",
320
+ /**
321
+ * Requests a web application to disable their tracking of a user. This is Mozilla's version of the X-Do-Not-Track header field (since Firefox 4.0 Beta 11). Safari and IE9 also have support for this field. On March 7, 2011, a draft proposal was submitted to IETF. The W3C Tracking Protection Working Group is producing a specification.
322
+ *
323
+ * @example
324
+ * DNT: 1 (Do Not Track Enabled)
325
+ DNT: 0 (Do Not Track Disabled)
326
+ */
327
+ DNT = "DNT",
328
+ /**
329
+ * A de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. Superseded by Forwarded header.
330
+ *
331
+ * @example
332
+ * X-Forwarded-For: client1, proxy1, proxy2
333
+ X-Forwarded-For: 129.78.138.66, 129.78.64.103
334
+ */
335
+ X_FORWARDED_FOR = "X-Forwarded-For",
336
+ /**
337
+ * A de facto standard for identifying the original host requested by the client in the Host HTTP request header, since the host name and/or port of the reverse proxy (load balancer) may differ from the origin server handling the request. Superseded by Forwarded header.
338
+ *
339
+ * @example
340
+ * X-Forwarded-Host: en.wikipedia.org:8080
341
+ X-Forwarded-Host: en.wikipedia.org
342
+ */
343
+ X_FORWARDED_HOST = "X-Forwarded-Host",
344
+ /**
345
+ * A de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (or a load balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS. An alternative form of the header (X-ProxyUser-Ip) is used by Google clients talking to Google servers. Superseded by Forwarded header.
346
+ *
347
+ * @example
348
+ * X-Forwarded-Proto: https
349
+ */
350
+ X_FORWARDED_PROTO = "X-Forwarded-Proto",
351
+ /**
352
+ * Non-standard header field used by Microsoft applications and load-balancers
353
+ *
354
+ * @example
355
+ * Front-End-Https: on
356
+ */
357
+ FRONT_END_HTTPS = "Front-End-Https",
358
+ /**
359
+ * Requests a web application to override the method specified in the request (typically POST) with the method given in the header field (typically PUT or DELETE). This can be used when a user agent or firewall prevents PUT or DELETE methods from being sent directly (note that this is either a bug in the software component, which ought to be fixed, or an intentional configuration, in which case bypassing it may be the wrong thing to do).
360
+ *
361
+ * @example
362
+ * X-HTTP-Method-Override: DELETE
363
+ */
364
+ X_HTTP_METHOD_OVERRIDE = "X-Http-Method-Override",
365
+ /**
366
+ * Allows easier parsing of the MakeModel/Firmware that is usually found in the User-Agent String of AT&T Devices
367
+ *
368
+ * @example
369
+ * X-Att-Deviceid: GT-P7320/P7320XXLPG
370
+ */
371
+ X_ATT_DEVICEID = "X-ATT-DeviceId",
372
+ /**
373
+ * Links to an XML file on the Internet with a full description and details about the device currently connecting. In the example to the right is an XML file for an AT&T Samsung Galaxy S2.
374
+ *
375
+ * @example
376
+ * x-wap-profile: http://wap.samsungmobile.com/uaprof/SGH-I777.xml
377
+ */
378
+ X_WAP_PROFILE = "X-Wap-Profile",
379
+ /**
380
+ * Implemented as a misunderstanding of the HTTP specifications. Common because of mistakes in implementations of early HTTP versions. Has exactly the same functionality as standard Connection field.
381
+ Must not be used with HTTP/2.
382
+ *
383
+ * @example
384
+ * Proxy-Connection: keep-alive
385
+ */
386
+ PROXY_CONNECTION = "Proxy-Connection",
387
+ /**
388
+ * Server-side deep packet insertion of a unique ID identifying customers of Verizon Wireless; also known as "perma-cookie" or "supercookie"
389
+ *
390
+ * @example
391
+ * X-UIDH: ...
392
+ */
393
+ X_UIDH = "X-UIDH",
394
+ /**
395
+ * Used to prevent cross-site request forgery. Alternative header names are: X-CSRFToken and X-XSRF-TOKEN
396
+ *
397
+ * @example
398
+ * X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
399
+ */
400
+ X_CSRF_TOKEN = "X-Csrf-Token",
401
+ /**
402
+ * Correlates HTTP requests between a client and server.
403
+ *
404
+ * @example
405
+ * X-Request-ID: f058ebd6-02f7-4d3f-942e-904344e8cde5
406
+ */
407
+ X_REQUEST_ID = "X-Request-ID",
408
+ /**
409
+ * Correlates HTTP requests between a client and server.
410
+ *
411
+ * @example
412
+ * X-Request-ID: f058ebd6-02f7-4d3f-942e-904344e8cde5
413
+ */
414
+ X_CORRELATION_ID = "X-Correlation-ID",
415
+ /**
416
+ * The Save-Data client hint request header available in Chrome, Opera, and Yandex browsers lets developers deliver lighter, faster applications to users who opt-in to data saving mode in their browser.
417
+ *
418
+ * @example
419
+ * Save-Data: on
420
+ */
421
+ SAVE_DATA = "Save-Data"
422
+ }
423
+ export declare enum HttpResponseHeader {
424
+ /**
425
+ * Specifying which web sites can participate in cross-origin resource sharing
426
+ *
427
+ * @example
428
+ * Access-Control-Allow-Origin: *
429
+ */
430
+ ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin",
431
+ /**
432
+ * Specifying which web sites can participate in cross-origin resource sharing
433
+ *
434
+ * @example
435
+ * Access-Control-Allow-Origin: *
436
+ */
437
+ ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials",
438
+ /**
439
+ * Specifying which web sites can participate in cross-origin resource sharing
440
+ *
441
+ * @example
442
+ * Access-Control-Allow-Origin: *
443
+ */
444
+ ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers",
445
+ /**
446
+ * Specifying which web sites can participate in cross-origin resource sharing
447
+ *
448
+ * @example
449
+ * Access-Control-Allow-Origin: *
450
+ */
451
+ ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age",
452
+ /**
453
+ * Specifying which web sites can participate in cross-origin resource sharing
454
+ *
455
+ * @example
456
+ * Access-Control-Allow-Origin: *
457
+ */
458
+ ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods",
459
+ /**
460
+ * Specifying which web sites can participate in cross-origin resource sharing
461
+ *
462
+ * @example
463
+ * Access-Control-Allow-Origin: *
464
+ */
465
+ ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers",
466
+ /**
467
+ * Specifies which patch document formats this server supports
468
+ *
469
+ * @example
470
+ * Accept-Patch: text/example;charset=utf-8
471
+ */
472
+ ACCEPT_PATCH = "Accept-Patch",
473
+ /**
474
+ * What partial content range types this server supports via byte serving
475
+ *
476
+ * @example
477
+ * Accept-Ranges: bytes
478
+ */
479
+ ACCEPT_RANGES = "Accept-Ranges",
480
+ /**
481
+ * The age the object has been in a proxy cache in seconds
482
+ *
483
+ * @example
484
+ * Age: 12
485
+ */
486
+ AGE = "Age",
487
+ /**
488
+ * Valid methods for a specified resource. To be used for a 405 Method not allowed
489
+ *
490
+ * @example
491
+ * Allow: GET, HEAD
492
+ */
493
+ ALLOW = "Allow",
494
+ /**
495
+ * A server uses "Alt-Svc" header (meaning Alternative Services) to indicate that its resources can also be accessed at a different network location (host or port) or using a different protocol
496
+ When using HTTP/2, servers should instead send an ALTSVC frame.
497
+ *
498
+ * @example
499
+ * Alt-Svc: http/1.1="http2.example.com:8001"; ma=7200
500
+ */
501
+ ALT_SVC = "Alt-Svc",
502
+ /**
503
+ * Tells all caching mechanisms from server to client whether they may cache this object. It is measured in seconds
504
+ *
505
+ * @example
506
+ * Cache-Control: max-age=3600
507
+ */
508
+ CACHE_CONTROL = "Cache-Control",
509
+ /**
510
+ * Control options for the current connection and list of hop-by-hop response fields.
511
+ Must not be used with HTTP/2.
512
+ *
513
+ * @example
514
+ * Connection: close
515
+ */
516
+ CONNECTION = "Connection",
517
+ /**
518
+ * An opportunity to raise a "File Download" dialogue box for a known MIME type with binary format or suggest a filename for dynamic content. Quotes are necessary with special characters.
519
+ *
520
+ * @example
521
+ * Content-Disposition: attachment; filename="fname.ext"
522
+ */
523
+ CONTENT_DISPOSITION = "Content-Disposition",
524
+ /**
525
+ * The type of encoding used on the data. See HTTP compression.
526
+ *
527
+ * @example
528
+ * Content-Encoding: gzip
529
+ */
530
+ CONTENT_ENCODING = "Content-Encoding",
531
+ /**
532
+ * The natural language or languages of the intended audience for the enclosed content
533
+ *
534
+ * @example
535
+ * Content-Language: da
536
+ */
537
+ CONTENT_LANGUAGE = "Content-Language",
538
+ /**
539
+ * The length of the response body in octets (8-bit bytes)
540
+ *
541
+ * @example
542
+ * Content-Length: 348
543
+ */
544
+ CONTENT_LENGTH = "Content-Length",
545
+ /**
546
+ * An alternate location for the returned data
547
+ *
548
+ * @example
549
+ * Content-Location: /index.htm
550
+ */
551
+ CONTENT_LOCATION = "Content-Location",
552
+ /**
553
+ * A Base64-encoded binary MD5 sum of the content of the response
554
+ *
555
+ * @example
556
+ * Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==
557
+ */
558
+ CONTENT_MD5 = "Content-MD5",
559
+ /**
560
+ * Where in a full body message this partial message belongs
561
+ *
562
+ * @example
563
+ * Content-Range: bytes 21010-47021/47022
564
+ */
565
+ CONTENT_RANGE = "Content-Range",
566
+ /**
567
+ * The MIME type of this content
568
+ *
569
+ * @example
570
+ * Content-Type: text/html; charset=utf-8
571
+ */
572
+ CONTENT_TYPE = "Content-Type",
573
+ /**
574
+ * The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231)
575
+ *
576
+ * @example
577
+ * Date: Tue, 15 Nov 1994 08:12:31 GMT
578
+ */
579
+ DATE = "Date",
580
+ /**
581
+ * Specifies the delta-encoding entity tag of the response.
582
+ *
583
+ * @example
584
+ * Delta-Base: "abc"
585
+ */
586
+ DELTA_BASE = "Delta-Base",
587
+ /**
588
+ * An identifier for a specific version of a resource, often a message digest
589
+ *
590
+ * @example
591
+ * ETag: "737060cd8c284d8af7ad3082f209582d"
592
+ */
593
+ ETAG = "ETag",
594
+ /**
595
+ * Gives the date/time after which the response is considered stale (in "HTTP-date" format as defined by RFC 7231)
596
+ *
597
+ * @example
598
+ * Expires: Thu, 01 Dec 1994 16:00:00 GMT
599
+ */
600
+ EXPIRES = "Expires",
601
+ /**
602
+ * Instance-manipulations applied to the response.
603
+ *
604
+ * @example
605
+ * IM: feed
606
+ */
607
+ IM = "IM",
608
+ /**
609
+ * The last modified date for the requested object (in "HTTP-date" format as defined by RFC 7231)
610
+ *
611
+ * @example
612
+ * Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
613
+ */
614
+ LAST_MODIFIED = "Last-Modified",
615
+ /**
616
+ * Used to express a typed relationship with another resource, where the relation type is defined by RFC 5988
617
+ *
618
+ * @example
619
+ * Link: </feed>; rel="alternate"[50]
620
+ */
621
+ LINK = "Link",
622
+ /**
623
+ * Used in redirection, or when a new resource has been created.
624
+ *
625
+ * @example
626
+ * Example 1: Location: http://www.w3.org/pub/WWW/People.html
627
+ Example 2: Location: /pub/WWW/People.html
628
+ */
629
+ LOCATION = "Location",
630
+ /**
631
+ * This field is supposed to set P3P policy, in the form of P3P:CP="your_compact_policy". However, P3P did not take off, most browsers have never fully implemented it, a lot of websites set this field with fake policy text, that was enough to fool browsers the existence of P3P policy and grant permissions for third party cookies.
632
+ *
633
+ * @example
634
+ * P3P: CP="This is not a P3P policy! See https://en.wikipedia.org/wiki/Special:CentralAutoLogin/P3P for more info."
635
+ */
636
+ P3P = "P3P",
637
+ /**
638
+ * Implementation-specific fields that may have various effects anywhere along the request-response chain.
639
+ *
640
+ * @example
641
+ * Pragma: no-cache
642
+ */
643
+ PRAGMA = "Pragma",
644
+ /**
645
+ * Request authentication to access the proxy.
646
+ *
647
+ * @example
648
+ * Proxy-Authenticate: Basic
649
+ */
650
+ PROXY_AUTHENTICATE = "Proxy-Authenticate",
651
+ /**
652
+ * HTTP Public Key Pinning, announces hash of website's authentic TLS certificate
653
+ *
654
+ * @example
655
+ * Public-Key-Pins: max-age=2592000; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
656
+ */
657
+ PUBLIC_KEY_PINS = "Public-Key-Pins",
658
+ /**
659
+ * If an entity is temporarily unavailable, this instructs the client to try again later. Value could be a specified period of time (in seconds) or a HTTP-date.
660
+ *
661
+ * @example
662
+ * Example 1: Retry-After: 120
663
+ Example 2: Retry-After: Fri, 07 Nov 2014 23:59:59 GMT
664
+ */
665
+ RETRY_AFTER = "Retry-After",
666
+ /**
667
+ * A name for the server
668
+ *
669
+ * @example
670
+ * Server: Apache/2.4.1 (Unix)
671
+ */
672
+ SERVER = "Server",
673
+ /**
674
+ * An HTTP cookie
675
+ *
676
+ * @example
677
+ * Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1
678
+ */
679
+ SET_COOKIE = "Set-Cookie",
680
+ /**
681
+ * A HSTS Policy informing the HTTP client how long to cache the HTTPS only policy and whether this applies to subdomains.
682
+ *
683
+ * @example
684
+ * Strict-Transport-Security: max-age=16070400; includeSubDomains
685
+ */
686
+ STRICT_TRANSPORT_SECURITY = "Strict-Transport-Security",
687
+ /**
688
+ * The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding.
689
+ *
690
+ * @example
691
+ * Trailer: Max-Forwards
692
+ */
693
+ TRAILER = "Trailer",
694
+ /**
695
+ * The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.
696
+ Must not be used with HTTP/2.
697
+ *
698
+ * @example
699
+ * Transfer-Encoding: chunked
700
+ */
701
+ TRANSFER_ENCODING = "Transfer-Encoding",
702
+ /**
703
+ * Tracking Status header, value suggested to be sent in response to a DNT(do-not-track), possible values:
704
+ "!" — under construction
705
+ "?" — dynamic
706
+ "G" — gateway to multiple parties
707
+ "N" — not tracking
708
+ "T" — tracking
709
+ "C" — tracking with consent
710
+ "P" — tracking only if consented
711
+ "D" — disregarding DNT
712
+ "U" — updated
713
+ *
714
+ * @example
715
+ * Tk: ?
716
+ */
717
+ TK = "Tk",
718
+ /**
719
+ * Ask the client to upgrade to another protocol.
720
+ Must not be used in HTTP/2
721
+ *
722
+ * @example
723
+ * Upgrade: h2c, HTTPS/1.3, IRC/6.9, RTA/x11, websocket
724
+ */
725
+ UPGRADE = "Upgrade",
726
+ /**
727
+ * Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server.
728
+ *
729
+ * @example
730
+ * Example 1: Vary: *
731
+ Example 2: Vary: Accept-Language
732
+ */
733
+ VARY = "Vary",
734
+ /**
735
+ * Informs the client of proxies through which the response was sent.
736
+ *
737
+ * @example
738
+ * Via: 1.0 fred, 1.1 example.com (Apache/1.1)
739
+ */
740
+ VIA = "Via",
741
+ /**
742
+ * A general warning about possible problems with the entity body.
743
+ *
744
+ * @example
745
+ * Warning: 199 Miscellaneous warning
746
+ */
747
+ WARNING = "Warning",
748
+ /**
749
+ * Indicates the authentication scheme that should be used to access the requested entity.
750
+ *
751
+ * @example
752
+ * WWW-Authenticate: Basic
753
+ */
754
+ WWW_AUTHENTICATE = "WWW-Authenticate",
755
+ /**
756
+ * Clickjacking protection: deny - no rendering within a frame, sameorigin - no rendering if origin mismatch, allow-from - allow from specified location, allowall - non-standard, allow from any location
757
+ *
758
+ * @example
759
+ * X-Frame-Options: deny
760
+ */
761
+ X_FRAME_OPTIONS = "X-Frame-Options",
762
+ /**
763
+ * Content Security Policy definition.
764
+ *
765
+ * @example
766
+ * X-WebKit-CSP: default-src 'self'
767
+ */
768
+ CONTENT_SECURITY_POLICY = "Content-Security-Policy",
769
+ /**
770
+ * Content Security Policy definition.
771
+ *
772
+ * @example
773
+ * X-WebKit-CSP: default-src 'self'
774
+ */
775
+ X_CONTENT_SECURITY_POLICY = "X-Content-Security-Policy",
776
+ /**
777
+ * Content Security Policy definition.
778
+ *
779
+ * @example
780
+ * X-WebKit-CSP: default-src 'self'
781
+ */
782
+ X_WEBKIT_CSP = "X-WebKit-CSP",
783
+ /**
784
+ * Used in redirection, or when a new resource has been created. This refresh redirects after 5 seconds. Header extension introduced by Netscape and supported by most web browsers.
785
+ *
786
+ * @example
787
+ * Refresh: 5; url=http://www.w3.org/pub/WWW/People.html
788
+ */
789
+ REFRESH = "Refresh",
790
+ /**
791
+ * CGI header field specifying the status of the HTTP response. Normal HTTP responses use a separate "Status-Line" instead, defined by RFC 7230.
792
+ *
793
+ * @example
794
+ * Status: 200 OK
795
+ */
796
+ STATUS = "Status",
797
+ /**
798
+ * The Timing-Allow-Origin response header specifies origins that are allowed to see values of attributes retrieved via features of the Resource Timing API, which would otherwise be reported as zero due to cross-origin restrictions.
799
+ *
800
+ * @example
801
+ * Timing-Allow-Origin: *
802
+ Timing-Allow-Origin: <origin>[, <origin>]*
803
+ */
804
+ TIMING_ALLOW_ORIGIN = "Timing-Allow-Origin",
805
+ /**
806
+ * Provide the duration of the audio or video in seconds; only supported by Gecko browsers
807
+ *
808
+ * @example
809
+ * X-Content-Duration: 42.666
810
+ */
811
+ X_CONTENT_DURATION = "X-Content-Duration",
812
+ /**
813
+ * The only defined value, "nosniff", prevents Internet Explorer from MIME-sniffing a response away from the declared content-type. This also applies to Google Chrome, when downloading extensions.
814
+ *
815
+ * @example
816
+ * X-Content-Type-Options: nosniff[62]
817
+ */
818
+ X_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options",
819
+ /**
820
+ * Specifies the technology (e.g. ASP.NET, PHP, JBoss) supporting the web application (version details are often in X-Runtime, X-Version, or X-AspNet-Version)
821
+ *
822
+ * @example
823
+ * X-Powered-By: PHP/5.4.0
824
+ */
825
+ X_POWERED_BY = "X-Powered-By",
826
+ /**
827
+ * Correlates HTTP requests between a client and server.
828
+ *
829
+ * @example
830
+ * X-Request-ID: f058ebd6-02f7-4d3f-942e-904344e8cde5
831
+ */
832
+ X_REQUEST_ID = "X-Request-ID",
833
+ /**
834
+ * Correlates HTTP requests between a client and server.
835
+ *
836
+ * @example
837
+ * X-Request-ID: f058ebd6-02f7-4d3f-942e-904344e8cde5
838
+ */
839
+ X_CORRELATION_ID = "X-Correlation-ID",
840
+ /**
841
+ * Recommends the preferred rendering engine (often a backward-compatibility mode) to use to display the content. Also used to activate Chrome Frame in Internet Explorer.
842
+ *
843
+ * @example
844
+ * X-UA-Compatible: IE=EmulateIE7
845
+ X-UA-Compatible: IE=edge
846
+ X-UA-Compatible: Chrome=1
847
+ */
848
+ X_UA_COMPATIBLE = "X-UA-Compatible",
849
+ /**
850
+ * Cross-site scripting (XSS) filter
851
+ *
852
+ * @example
853
+ * X-XSS-Protection: 1; mode=block
854
+ */
855
+ X_XSS_PROTECTION = "X-XSS-Protection"
856
+ }
@@ -0,0 +1,142 @@
1
+ // https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
2
+
3
+ /**
4
+ [...$0.querySelectorAll('tr')].map(v => v.querySelector('td:nth-child(1)').innerText.trim().split(',').map(name => name.replace(/\[.*?\]/g, '').trim()).map((name) => ({
5
+ name: name,
6
+ description: v.querySelector('td:nth-child(2)').innerText.replace(/\[.*?\]/g, '').trim(),
7
+ example: v.querySelector('td:nth-child(3)').innerText.trim(),
8
+ pascalName: name.replace(/\-/g, '_').toUpperCase()
9
+ }))).flat().map(item => `
10
+ ${'/'}**
11
+ * ${item.description}
12
+ *
13
+ * @example
14
+ * ${item.example}
15
+ *${'/'}
16
+ ${item.pascalName} = '${item.name}',
17
+ `).join('\n\n')
18
+ */
19
+ export let HttpRequestHeader;
20
+
21
+ (function (HttpRequestHeader) {
22
+ HttpRequestHeader["A_IM"] = "A-IM";
23
+ HttpRequestHeader["ACCEPT"] = "Accept";
24
+ HttpRequestHeader["ACCEPT_CHARSET"] = "Accept-Charset";
25
+ HttpRequestHeader["ACCEPT_DATETIME"] = "Accept-Datetime";
26
+ HttpRequestHeader["ACCEPT_ENCODING"] = "Accept-Encoding";
27
+ HttpRequestHeader["ACCEPT_LANGUAGE"] = "Accept-Language";
28
+ HttpRequestHeader["ACCESS_CONTROL_REQUEST_METHOD"] = "Access-Control-Request-Method";
29
+ HttpRequestHeader["ACCESS_CONTROL_REQUEST_HEADERS"] = "Access-Control-Request-Headers";
30
+ HttpRequestHeader["AUTHORIZATION"] = "Authorization";
31
+ HttpRequestHeader["CACHE_CONTROL"] = "Cache-Control";
32
+ HttpRequestHeader["CONNECTION"] = "Connection";
33
+ HttpRequestHeader["CONTENT_ENCODING"] = "Content-Encoding";
34
+ HttpRequestHeader["CONTENT_LENGTH"] = "Content-Length";
35
+ HttpRequestHeader["CONTENT_MD5"] = "Content-MD5";
36
+ HttpRequestHeader["CONTENT_TYPE"] = "Content-Type";
37
+ HttpRequestHeader["COOKIE"] = "Cookie";
38
+ HttpRequestHeader["DATE"] = "Date";
39
+ HttpRequestHeader["EXPECT"] = "Expect";
40
+ HttpRequestHeader["FORWARDED"] = "Forwarded";
41
+ HttpRequestHeader["FROM"] = "From";
42
+ HttpRequestHeader["HOST"] = "Host";
43
+ HttpRequestHeader["HTTP2_SETTINGS"] = "HTTP2-Settings";
44
+ HttpRequestHeader["IF_MATCH"] = "If-Match";
45
+ HttpRequestHeader["IF_MODIFIED_SINCE"] = "If-Modified-Since";
46
+ HttpRequestHeader["IF_NONE_MATCH"] = "If-None-Match";
47
+ HttpRequestHeader["IF_RANGE"] = "If-Range";
48
+ HttpRequestHeader["IF_UNMODIFIED_SINCE"] = "If-Unmodified-Since";
49
+ HttpRequestHeader["MAX_FORWARDS"] = "Max-Forwards";
50
+ HttpRequestHeader["ORIGIN"] = "Origin";
51
+ HttpRequestHeader["PRAGMA"] = "Pragma";
52
+ HttpRequestHeader["PROXY_AUTHORIZATION"] = "Proxy-Authorization";
53
+ HttpRequestHeader["RANGE"] = "Range";
54
+ HttpRequestHeader["REFERER"] = "Referer";
55
+ HttpRequestHeader["TE"] = "TE";
56
+ HttpRequestHeader["TRAILER"] = "Trailer";
57
+ HttpRequestHeader["TRANSFER_ENCODING"] = "Transfer-Encoding";
58
+ HttpRequestHeader["USER_AGENT"] = "User-Agent";
59
+ HttpRequestHeader["UPGRADE"] = "Upgrade";
60
+ HttpRequestHeader["VIA"] = "Via";
61
+ HttpRequestHeader["WARNING"] = "Warning";
62
+ HttpRequestHeader["UPGRADE_INSECURE_REQUESTS"] = "Upgrade-Insecure-Requests";
63
+ HttpRequestHeader["X_REQUESTED_WITH"] = "X-Requested-With";
64
+ HttpRequestHeader["DNT"] = "DNT";
65
+ HttpRequestHeader["X_FORWARDED_FOR"] = "X-Forwarded-For";
66
+ HttpRequestHeader["X_FORWARDED_HOST"] = "X-Forwarded-Host";
67
+ HttpRequestHeader["X_FORWARDED_PROTO"] = "X-Forwarded-Proto";
68
+ HttpRequestHeader["FRONT_END_HTTPS"] = "Front-End-Https";
69
+ HttpRequestHeader["X_HTTP_METHOD_OVERRIDE"] = "X-Http-Method-Override";
70
+ HttpRequestHeader["X_ATT_DEVICEID"] = "X-ATT-DeviceId";
71
+ HttpRequestHeader["X_WAP_PROFILE"] = "X-Wap-Profile";
72
+ HttpRequestHeader["PROXY_CONNECTION"] = "Proxy-Connection";
73
+ HttpRequestHeader["X_UIDH"] = "X-UIDH";
74
+ HttpRequestHeader["X_CSRF_TOKEN"] = "X-Csrf-Token";
75
+ HttpRequestHeader["X_REQUEST_ID"] = "X-Request-ID";
76
+ HttpRequestHeader["X_CORRELATION_ID"] = "X-Correlation-ID";
77
+ HttpRequestHeader["SAVE_DATA"] = "Save-Data";
78
+ })(HttpRequestHeader || (HttpRequestHeader = {}));
79
+
80
+ export let HttpResponseHeader;
81
+
82
+ (function (HttpResponseHeader) {
83
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_ORIGIN"] = "Access-Control-Allow-Origin";
84
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_CREDENTIALS"] = "Access-Control-Allow-Credentials";
85
+ HttpResponseHeader["ACCESS_CONTROL_EXPOSE_HEADERS"] = "Access-Control-Expose-Headers";
86
+ HttpResponseHeader["ACCESS_CONTROL_MAX_AGE"] = "Access-Control-Max-Age";
87
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_METHODS"] = "Access-Control-Allow-Methods";
88
+ HttpResponseHeader["ACCESS_CONTROL_ALLOW_HEADERS"] = "Access-Control-Allow-Headers";
89
+ HttpResponseHeader["ACCEPT_PATCH"] = "Accept-Patch";
90
+ HttpResponseHeader["ACCEPT_RANGES"] = "Accept-Ranges";
91
+ HttpResponseHeader["AGE"] = "Age";
92
+ HttpResponseHeader["ALLOW"] = "Allow";
93
+ HttpResponseHeader["ALT_SVC"] = "Alt-Svc";
94
+ HttpResponseHeader["CACHE_CONTROL"] = "Cache-Control";
95
+ HttpResponseHeader["CONNECTION"] = "Connection";
96
+ HttpResponseHeader["CONTENT_DISPOSITION"] = "Content-Disposition";
97
+ HttpResponseHeader["CONTENT_ENCODING"] = "Content-Encoding";
98
+ HttpResponseHeader["CONTENT_LANGUAGE"] = "Content-Language";
99
+ HttpResponseHeader["CONTENT_LENGTH"] = "Content-Length";
100
+ HttpResponseHeader["CONTENT_LOCATION"] = "Content-Location";
101
+ HttpResponseHeader["CONTENT_MD5"] = "Content-MD5";
102
+ HttpResponseHeader["CONTENT_RANGE"] = "Content-Range";
103
+ HttpResponseHeader["CONTENT_TYPE"] = "Content-Type";
104
+ HttpResponseHeader["DATE"] = "Date";
105
+ HttpResponseHeader["DELTA_BASE"] = "Delta-Base";
106
+ HttpResponseHeader["ETAG"] = "ETag";
107
+ HttpResponseHeader["EXPIRES"] = "Expires";
108
+ HttpResponseHeader["IM"] = "IM";
109
+ HttpResponseHeader["LAST_MODIFIED"] = "Last-Modified";
110
+ HttpResponseHeader["LINK"] = "Link";
111
+ HttpResponseHeader["LOCATION"] = "Location";
112
+ HttpResponseHeader["P3P"] = "P3P";
113
+ HttpResponseHeader["PRAGMA"] = "Pragma";
114
+ HttpResponseHeader["PROXY_AUTHENTICATE"] = "Proxy-Authenticate";
115
+ HttpResponseHeader["PUBLIC_KEY_PINS"] = "Public-Key-Pins";
116
+ HttpResponseHeader["RETRY_AFTER"] = "Retry-After";
117
+ HttpResponseHeader["SERVER"] = "Server";
118
+ HttpResponseHeader["SET_COOKIE"] = "Set-Cookie";
119
+ HttpResponseHeader["STRICT_TRANSPORT_SECURITY"] = "Strict-Transport-Security";
120
+ HttpResponseHeader["TRAILER"] = "Trailer";
121
+ HttpResponseHeader["TRANSFER_ENCODING"] = "Transfer-Encoding";
122
+ HttpResponseHeader["TK"] = "Tk";
123
+ HttpResponseHeader["UPGRADE"] = "Upgrade";
124
+ HttpResponseHeader["VARY"] = "Vary";
125
+ HttpResponseHeader["VIA"] = "Via";
126
+ HttpResponseHeader["WARNING"] = "Warning";
127
+ HttpResponseHeader["WWW_AUTHENTICATE"] = "WWW-Authenticate";
128
+ HttpResponseHeader["X_FRAME_OPTIONS"] = "X-Frame-Options";
129
+ HttpResponseHeader["CONTENT_SECURITY_POLICY"] = "Content-Security-Policy";
130
+ HttpResponseHeader["X_CONTENT_SECURITY_POLICY"] = "X-Content-Security-Policy";
131
+ HttpResponseHeader["X_WEBKIT_CSP"] = "X-WebKit-CSP";
132
+ HttpResponseHeader["REFRESH"] = "Refresh";
133
+ HttpResponseHeader["STATUS"] = "Status";
134
+ HttpResponseHeader["TIMING_ALLOW_ORIGIN"] = "Timing-Allow-Origin";
135
+ HttpResponseHeader["X_CONTENT_DURATION"] = "X-Content-Duration";
136
+ HttpResponseHeader["X_CONTENT_TYPE_OPTIONS"] = "X-Content-Type-Options";
137
+ HttpResponseHeader["X_POWERED_BY"] = "X-Powered-By";
138
+ HttpResponseHeader["X_REQUEST_ID"] = "X-Request-ID";
139
+ HttpResponseHeader["X_CORRELATION_ID"] = "X-Correlation-ID";
140
+ HttpResponseHeader["X_UA_COMPATIBLE"] = "X-UA-Compatible";
141
+ HttpResponseHeader["X_XSS_PROTECTION"] = "X-XSS-Protection";
142
+ })(HttpResponseHeader || (HttpResponseHeader = {}));
@@ -87,7 +87,7 @@ export class Server {
87
87
  await item.handler.handle(undefined, {
88
88
  url: url,
89
89
  headers: req.headers,
90
- setHeader: res.header,
90
+ setHeader: (k, v) => res.header(k, v),
91
91
  redirect: undefined,
92
92
  ws: req
93
93
  });
@@ -115,7 +115,7 @@ export class Server {
115
115
  }, {
116
116
  url: url,
117
117
  headers: req.headers,
118
- setHeader: res.header,
118
+ setHeader: (k, v) => res.header(k, v),
119
119
  redirect: url => res.redirect(url),
120
120
  ws: undefined
121
121
  });
@@ -2,7 +2,7 @@
2
2
  import { BasePlugin } from '../plugins/base';
3
3
  import { BaseService } from '../services/base';
4
4
  import { yup } from 'vtils/validator';
5
- import type { AsyncOrSync, OneOrMore, RequiredDeep } from 'vtils/types';
5
+ import type { AsyncOrSync, LiteralUnion, OneOrMore, RequiredDeep } from 'vtils/types';
6
6
  import type { DisposeService } from '../services/dispose';
7
7
  import type { Handler } from './handler';
8
8
  import type { IncomingHttpHeaders } from 'http';
@@ -56,7 +56,7 @@ export declare namespace XHandler {
56
56
  /**
57
57
  * 设置响应头
58
58
  */
59
- setHeader: (key: keyof IncomingHttpHeaders, value: string) => void;
59
+ setHeader: (key: string, value: string) => void;
60
60
  /**
61
61
  * HTTP 跳转
62
62
  */
@@ -98,6 +98,10 @@ export declare namespace XHandler {
98
98
  * @default false
99
99
  */
100
100
  responseDataPack?: boolean;
101
+ /**
102
+ * 响应的 Content-Type 头
103
+ */
104
+ responseContentType?: LiteralUnion<'text/html', string>;
101
105
  /**
102
106
  * 请求数据验证结构
103
107
  */
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './core/define_server';
5
5
  export * from './core/define_task';
6
6
  export * from './core/handler';
7
7
  export * from './core/http_error';
8
+ export * from './core/http_header';
8
9
  export * from './core/http_method';
9
10
  export * from './core/server';
10
11
  export * from './core/types';
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@ export * from "./core/define_server";
6
6
  export * from "./core/define_task";
7
7
  export * from "./core/handler";
8
8
  export * from "./core/http_error";
9
+ export * from "./core/http_header";
9
10
  export * from "./core/http_method";
10
11
  export * from "./core/server";
11
12
  export * from "./core/types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "1.18.0",
3
+ "version": "1.20.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",