@opra/common 0.19.0 → 0.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/browser.js +117 -683
- package/cjs/document/data-type/builtin/index.js +2 -0
- package/cjs/document/data-type/builtin/null.type.js +15 -0
- package/cjs/document/data-type/builtin/object-id.type.js +15 -0
- package/cjs/document/data-type/complex-type.js +1 -0
- package/cjs/document/data-type/enum-type.js +1 -0
- package/cjs/document/data-type/mapped-type.js +1 -0
- package/cjs/document/data-type/simple-type.js +1 -0
- package/cjs/document/data-type/union-type.js +1 -0
- package/cjs/document/factory/create-document.js +3 -3
- package/cjs/http/index.js +1 -2
- package/esm/document/data-type/builtin/index.js +2 -0
- package/esm/document/data-type/builtin/null.type.js +12 -0
- package/esm/document/data-type/builtin/object-id.type.js +12 -0
- package/esm/document/data-type/complex-type.js +1 -0
- package/esm/document/data-type/enum-type.js +1 -0
- package/esm/document/data-type/mapped-type.js +1 -0
- package/esm/document/data-type/simple-type.js +1 -0
- package/esm/document/data-type/union-type.js +1 -0
- package/esm/document/factory/create-document.js +4 -4
- package/esm/http/index.js +1 -2
- package/package.json +9 -24
- package/types/document/data-type/builtin/index.d.ts +2 -0
- package/types/document/data-type/builtin/null.type.d.ts +2 -0
- package/types/document/data-type/builtin/object-id.type.d.ts +2 -0
- package/types/document/data-type/complex-type.d.ts +1 -0
- package/types/document/data-type/enum-type.d.ts +1 -0
- package/types/document/data-type/mapped-type.d.ts +1 -0
- package/types/document/data-type/simple-type.d.ts +1 -0
- package/types/document/data-type/union-type.d.ts +1 -0
- package/types/exception/error-issue.d.ts +1 -1
- package/types/http/index.d.ts +1 -2
- package/cjs/http/http-message.host.js +0 -251
- package/cjs/http/http-request-message.js +0 -152
- package/cjs/http/http-response-message.js +0 -238
- package/cjs/http/interfaces/cookie-options.interface.js +0 -2
- package/esm/http/http-message.host.js +0 -246
- package/esm/http/http-request-message.js +0 -148
- package/esm/http/http-response-message.js +0 -233
- package/esm/http/interfaces/cookie-options.interface.js +0 -1
- package/types/http/http-message.host.d.ts +0 -122
- package/types/http/http-request-message.d.ts +0 -213
- package/types/http/http-response-message.d.ts +0 -318
- package/types/http/interfaces/cookie-options.interface.d.ts +0 -4
package/browser.js
CHANGED
|
@@ -32,8 +32,8 @@ function isConstructor(fn) {
|
|
|
32
32
|
return typeof fn === "function" && fn.prototype && fn.prototype.constructor === fn && fn.prototype.constructor.name !== "Function" && fn.prototype.constructor.name !== "anonymous";
|
|
33
33
|
}
|
|
34
34
|
__name(isConstructor, "isConstructor");
|
|
35
|
-
function isStream(
|
|
36
|
-
return
|
|
35
|
+
function isStream(stream) {
|
|
36
|
+
return stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
|
|
37
37
|
}
|
|
38
38
|
__name(isStream, "isStream");
|
|
39
39
|
function isReadable(x) {
|
|
@@ -968,11 +968,13 @@ function isContainer(obj) {
|
|
|
968
968
|
__name(isContainer, "isContainer");
|
|
969
969
|
|
|
970
970
|
// ../../build/common/esm/document/data-type/complex-type.js
|
|
971
|
+
import "reflect-metadata";
|
|
971
972
|
import omit2 from "lodash.omit";
|
|
972
973
|
import merge3 from "putil-merge";
|
|
973
974
|
import * as vg2 from "valgen";
|
|
974
975
|
|
|
975
976
|
// ../../build/common/esm/document/data-type/enum-type.js
|
|
977
|
+
import "reflect-metadata";
|
|
976
978
|
import omit from "lodash.omit";
|
|
977
979
|
import merge2 from "putil-merge";
|
|
978
980
|
import * as vg from "valgen";
|
|
@@ -1215,8 +1217,8 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1215
1217
|
throw new Error(`Unknown field "${nameOrPath}"`);
|
|
1216
1218
|
return field;
|
|
1217
1219
|
}
|
|
1218
|
-
iteratePath(
|
|
1219
|
-
const arr =
|
|
1220
|
+
iteratePath(path2, silent) {
|
|
1221
|
+
const arr = path2.split(".");
|
|
1220
1222
|
const len = arr.length;
|
|
1221
1223
|
let dataType = this;
|
|
1222
1224
|
let field;
|
|
@@ -1484,11 +1486,11 @@ var ApiDocument = class {
|
|
|
1484
1486
|
return t;
|
|
1485
1487
|
throw new NotAcceptableError(`Data type "${t.name || t}" is not a SimpleType`);
|
|
1486
1488
|
}
|
|
1487
|
-
getResource(
|
|
1489
|
+
getResource(path2, silent) {
|
|
1488
1490
|
let resource;
|
|
1489
|
-
const m = NAMESPACE_PATTERN.exec(
|
|
1491
|
+
const m = NAMESPACE_PATTERN.exec(path2);
|
|
1490
1492
|
if (!m)
|
|
1491
|
-
throw new NotFoundError(`Invalid resource path "${
|
|
1493
|
+
throw new NotFoundError(`Invalid resource path "${path2}"`);
|
|
1492
1494
|
if (m[2]) {
|
|
1493
1495
|
const ref = this.references.get(m[1]);
|
|
1494
1496
|
if (!ref) {
|
|
@@ -1511,18 +1513,18 @@ var ApiDocument = class {
|
|
|
1511
1513
|
}
|
|
1512
1514
|
if (silent)
|
|
1513
1515
|
return;
|
|
1514
|
-
throw new NotFoundError(`Resource not found (${
|
|
1516
|
+
throw new NotFoundError(`Resource not found (${path2})`);
|
|
1515
1517
|
}
|
|
1516
|
-
getCollection(
|
|
1517
|
-
const t = this.getResource(
|
|
1518
|
+
getCollection(path2, silent) {
|
|
1519
|
+
const t = this.getResource(path2);
|
|
1518
1520
|
if (!t && silent)
|
|
1519
1521
|
return;
|
|
1520
1522
|
if (t && t.kind === opra_schema_ns_exports.Collection.Kind)
|
|
1521
1523
|
return t;
|
|
1522
1524
|
throw new NotAcceptableError(`Resource type "${t.name}" is not a Collection`);
|
|
1523
1525
|
}
|
|
1524
|
-
getSingleton(
|
|
1525
|
-
const t = this.getResource(
|
|
1526
|
+
getSingleton(path2, silent) {
|
|
1527
|
+
const t = this.getResource(path2);
|
|
1526
1528
|
if (!t && silent)
|
|
1527
1529
|
return;
|
|
1528
1530
|
if (t && t.kind === opra_schema_ns_exports.Singleton.Kind)
|
|
@@ -1600,6 +1602,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
1600
1602
|
__name(__decorate, "__decorate");
|
|
1601
1603
|
|
|
1602
1604
|
// ../../build/common/esm/document/data-type/simple-type.js
|
|
1605
|
+
import "reflect-metadata";
|
|
1603
1606
|
import omit3 from "lodash.omit";
|
|
1604
1607
|
import merge4 from "putil-merge";
|
|
1605
1608
|
import * as vg3 from "valgen";
|
|
@@ -1756,6 +1759,21 @@ IntegerType = __decorate([
|
|
|
1756
1759
|
})
|
|
1757
1760
|
], IntegerType);
|
|
1758
1761
|
|
|
1762
|
+
// ../../build/common/esm/document/data-type/builtin/null.type.js
|
|
1763
|
+
import { isNull } from "valgen";
|
|
1764
|
+
var NullType = class NullType2 {
|
|
1765
|
+
static {
|
|
1766
|
+
__name(this, "NullType");
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
NullType = __decorate([
|
|
1770
|
+
SimpleType2({
|
|
1771
|
+
description: "A Null value",
|
|
1772
|
+
decoder: isNull(),
|
|
1773
|
+
encoder: isNull()
|
|
1774
|
+
})
|
|
1775
|
+
], NullType);
|
|
1776
|
+
|
|
1759
1777
|
// ../../build/common/esm/document/data-type/builtin/number.type.js
|
|
1760
1778
|
import { isNumber } from "valgen";
|
|
1761
1779
|
var NumberType = class NumberType2 {
|
|
@@ -1786,8 +1804,23 @@ ObjectType = __decorate([
|
|
|
1786
1804
|
})
|
|
1787
1805
|
], ObjectType);
|
|
1788
1806
|
|
|
1807
|
+
// ../../build/common/esm/document/data-type/builtin/object-id.type.js
|
|
1808
|
+
import { isObjectId, isString as isString2, pipe as pipe2 } from "valgen";
|
|
1809
|
+
var ObjectIdType = class ObjectIdType2 {
|
|
1810
|
+
static {
|
|
1811
|
+
__name(this, "ObjectIdType");
|
|
1812
|
+
}
|
|
1813
|
+
};
|
|
1814
|
+
ObjectIdType = __decorate([
|
|
1815
|
+
SimpleType2({
|
|
1816
|
+
description: "A MongoDB ObjectID value",
|
|
1817
|
+
decoder: isObjectId(),
|
|
1818
|
+
encoder: pipe2(isObjectId(), isString2())
|
|
1819
|
+
})
|
|
1820
|
+
], ObjectIdType);
|
|
1821
|
+
|
|
1789
1822
|
// ../../build/common/esm/document/data-type/builtin/string.type.js
|
|
1790
|
-
import { isString as
|
|
1823
|
+
import { isString as isString3 } from "valgen";
|
|
1791
1824
|
var StringType = class StringType2 {
|
|
1792
1825
|
static {
|
|
1793
1826
|
__name(this, "StringType");
|
|
@@ -1796,8 +1829,8 @@ var StringType = class StringType2 {
|
|
|
1796
1829
|
StringType = __decorate([
|
|
1797
1830
|
SimpleType2({
|
|
1798
1831
|
description: "A sequence of characters",
|
|
1799
|
-
decoder:
|
|
1800
|
-
encoder:
|
|
1832
|
+
decoder: isString3(),
|
|
1833
|
+
encoder: isString3()
|
|
1801
1834
|
})
|
|
1802
1835
|
], StringType);
|
|
1803
1836
|
|
|
@@ -1909,8 +1942,10 @@ async function createBuiltinTypeDocument() {
|
|
|
1909
1942
|
DateType,
|
|
1910
1943
|
UuidType,
|
|
1911
1944
|
IntegerType,
|
|
1945
|
+
NullType,
|
|
1912
1946
|
NumberType,
|
|
1913
1947
|
ObjectType,
|
|
1948
|
+
ObjectIdType,
|
|
1914
1949
|
StringType,
|
|
1915
1950
|
TimeType,
|
|
1916
1951
|
TimestampType
|
|
@@ -9691,8 +9726,8 @@ var CollectionClass = class extends Resource {
|
|
|
9691
9726
|
return result;
|
|
9692
9727
|
}
|
|
9693
9728
|
}
|
|
9694
|
-
normalizeFieldPath(
|
|
9695
|
-
return this.type.normalizeFieldPath(
|
|
9729
|
+
normalizeFieldPath(path2) {
|
|
9730
|
+
return this.type.normalizeFieldPath(path2);
|
|
9696
9731
|
}
|
|
9697
9732
|
normalizeSortFields(fields) {
|
|
9698
9733
|
const normalized = this.type.normalizeFieldPath(fields);
|
|
@@ -9813,8 +9848,8 @@ var SingletonClass = class extends Resource {
|
|
|
9813
9848
|
}));
|
|
9814
9849
|
return out;
|
|
9815
9850
|
}
|
|
9816
|
-
normalizeFieldPath(
|
|
9817
|
-
return this.type.normalizeFieldPath(
|
|
9851
|
+
normalizeFieldPath(path2) {
|
|
9852
|
+
return this.type.normalizeFieldPath(path2);
|
|
9818
9853
|
}
|
|
9819
9854
|
};
|
|
9820
9855
|
var Singleton2 = /* @__PURE__ */ __name(function(...args) {
|
|
@@ -9908,6 +9943,7 @@ async function createSingleton(name, schema) {
|
|
|
9908
9943
|
__name(createSingleton, "createSingleton");
|
|
9909
9944
|
|
|
9910
9945
|
// ../../build/common/esm/document/data-type/mapped-type.js
|
|
9946
|
+
import "reflect-metadata";
|
|
9911
9947
|
import merge7 from "putil-merge";
|
|
9912
9948
|
import * as vg4 from "valgen";
|
|
9913
9949
|
var MappedTypeClass = class extends DataType {
|
|
@@ -10038,6 +10074,7 @@ function OmitType(classRef, keys) {
|
|
|
10038
10074
|
__name(OmitType, "OmitType");
|
|
10039
10075
|
|
|
10040
10076
|
// ../../build/common/esm/document/data-type/union-type.js
|
|
10077
|
+
import "reflect-metadata";
|
|
10041
10078
|
import merge8 from "putil-merge";
|
|
10042
10079
|
import * as vg5 from "valgen";
|
|
10043
10080
|
var UnionTypeClass = class extends DataType {
|
|
@@ -11165,14 +11202,66 @@ function encodeURIParam(v) {
|
|
|
11165
11202
|
}
|
|
11166
11203
|
__name(encodeURIParam, "encodeURIParam");
|
|
11167
11204
|
|
|
11168
|
-
// ../../build/common/esm/http/http-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11205
|
+
// ../../build/common/esm/http/enums/http-status-codes.enum.js
|
|
11206
|
+
var HttpStatusCodes;
|
|
11207
|
+
(function(HttpStatusCodes2) {
|
|
11208
|
+
HttpStatusCodes2[HttpStatusCodes2["CONTINUE"] = 100] = "CONTINUE";
|
|
11209
|
+
HttpStatusCodes2[HttpStatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
11210
|
+
HttpStatusCodes2[HttpStatusCodes2["PROCESSING"] = 102] = "PROCESSING";
|
|
11211
|
+
HttpStatusCodes2[HttpStatusCodes2["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
11212
|
+
HttpStatusCodes2[HttpStatusCodes2["OK"] = 200] = "OK";
|
|
11213
|
+
HttpStatusCodes2[HttpStatusCodes2["CREATED"] = 201] = "CREATED";
|
|
11214
|
+
HttpStatusCodes2[HttpStatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
11215
|
+
HttpStatusCodes2[HttpStatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
11216
|
+
HttpStatusCodes2[HttpStatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
11217
|
+
HttpStatusCodes2[HttpStatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
11218
|
+
HttpStatusCodes2[HttpStatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
11219
|
+
HttpStatusCodes2[HttpStatusCodes2["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
11220
|
+
HttpStatusCodes2[HttpStatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
11221
|
+
HttpStatusCodes2[HttpStatusCodes2["FOUND"] = 302] = "FOUND";
|
|
11222
|
+
HttpStatusCodes2[HttpStatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
11223
|
+
HttpStatusCodes2[HttpStatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
11224
|
+
HttpStatusCodes2[HttpStatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
11225
|
+
HttpStatusCodes2[HttpStatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
11226
|
+
HttpStatusCodes2[HttpStatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
11227
|
+
HttpStatusCodes2[HttpStatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
11228
|
+
HttpStatusCodes2[HttpStatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
11229
|
+
HttpStatusCodes2[HttpStatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
11230
|
+
HttpStatusCodes2[HttpStatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
11231
|
+
HttpStatusCodes2[HttpStatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
11232
|
+
HttpStatusCodes2[HttpStatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
11233
|
+
HttpStatusCodes2[HttpStatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
11234
|
+
HttpStatusCodes2[HttpStatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
11235
|
+
HttpStatusCodes2[HttpStatusCodes2["CONFLICT"] = 409] = "CONFLICT";
|
|
11236
|
+
HttpStatusCodes2[HttpStatusCodes2["GONE"] = 410] = "GONE";
|
|
11237
|
+
HttpStatusCodes2[HttpStatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
11238
|
+
HttpStatusCodes2[HttpStatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
11239
|
+
HttpStatusCodes2[HttpStatusCodes2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
11240
|
+
HttpStatusCodes2[HttpStatusCodes2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
11241
|
+
HttpStatusCodes2[HttpStatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
11242
|
+
HttpStatusCodes2[HttpStatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
11243
|
+
HttpStatusCodes2[HttpStatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
11244
|
+
HttpStatusCodes2[HttpStatusCodes2["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
11245
|
+
HttpStatusCodes2[HttpStatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
11246
|
+
HttpStatusCodes2[HttpStatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
11247
|
+
HttpStatusCodes2[HttpStatusCodes2["LOCKED"] = 423] = "LOCKED";
|
|
11248
|
+
HttpStatusCodes2[HttpStatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
11249
|
+
HttpStatusCodes2[HttpStatusCodes2["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
11250
|
+
HttpStatusCodes2[HttpStatusCodes2["UPGRADE_REQUIRED"] = 428] = "UPGRADE_REQUIRED";
|
|
11251
|
+
HttpStatusCodes2[HttpStatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
11252
|
+
HttpStatusCodes2[HttpStatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
11253
|
+
HttpStatusCodes2[HttpStatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
11254
|
+
HttpStatusCodes2[HttpStatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
11255
|
+
HttpStatusCodes2[HttpStatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
11256
|
+
HttpStatusCodes2[HttpStatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
11257
|
+
HttpStatusCodes2[HttpStatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
11258
|
+
HttpStatusCodes2[HttpStatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
11259
|
+
HttpStatusCodes2[HttpStatusCodes2["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
11260
|
+
HttpStatusCodes2[HttpStatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
11261
|
+
HttpStatusCodes2[HttpStatusCodes2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
11262
|
+
HttpStatusCodes2[HttpStatusCodes2["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
11263
|
+
HttpStatusCodes2[HttpStatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
11264
|
+
})(HttpStatusCodes || (HttpStatusCodes = {}));
|
|
11176
11265
|
|
|
11177
11266
|
// ../../build/common/esm/http/enums/http-status-messages.js
|
|
11178
11267
|
var HttpStatusMessages = {
|
|
@@ -11241,659 +11330,6 @@ var HttpStatusMessages = {
|
|
|
11241
11330
|
"511": "Network Authentication Required"
|
|
11242
11331
|
};
|
|
11243
11332
|
|
|
11244
|
-
// ../../build/common/esm/http/http-message.host.js
|
|
11245
|
-
import stream from "@browsery/stream";
|
|
11246
|
-
import { HTTPParser } from "@browsery/http-parser";
|
|
11247
|
-
var kHeaders = Symbol("kHeaders");
|
|
11248
|
-
var kHeadersProxy = Symbol("kHeadersProxy");
|
|
11249
|
-
var kTrailers = Symbol("kTrailers");
|
|
11250
|
-
var kTrailersProxy = Symbol("kTrailersProxy");
|
|
11251
|
-
var kOnHeaderReceived = Symbol("kOnHeaderReceived");
|
|
11252
|
-
var kOnTrailersReceived = Symbol("kOnTrailersReceived");
|
|
11253
|
-
var kOnBodyChunk = Symbol("kOnBodyChunk");
|
|
11254
|
-
var kOnReadComplete = Symbol("kOnReadComplete");
|
|
11255
|
-
var crlfBuffer = Buffer.from("\r\n");
|
|
11256
|
-
var HTTP_VERSION_PATTERN = /^(\d)\.(\d)$/;
|
|
11257
|
-
var HttpMessageHost = class {
|
|
11258
|
-
static {
|
|
11259
|
-
__name(this, "HttpMessageHost");
|
|
11260
|
-
}
|
|
11261
|
-
constructor() {
|
|
11262
|
-
this.complete = false;
|
|
11263
|
-
stream.Duplex.apply(this);
|
|
11264
|
-
this[kHeaders] = new HttpHeaders(void 0, {
|
|
11265
|
-
onChange: () => this._headersChanged = true
|
|
11266
|
-
});
|
|
11267
|
-
this[kTrailers] = new HttpHeaders(void 0, {
|
|
11268
|
-
onChange: () => this._trailersChanged = true
|
|
11269
|
-
});
|
|
11270
|
-
}
|
|
11271
|
-
get httpVersion() {
|
|
11272
|
-
return this.httpVersionMajor ? this.httpVersionMajor + "." + (this.httpVersionMinor || 0) : void 0;
|
|
11273
|
-
}
|
|
11274
|
-
set httpVersion(value) {
|
|
11275
|
-
if (value) {
|
|
11276
|
-
const m = HTTP_VERSION_PATTERN.exec(value);
|
|
11277
|
-
if (!m)
|
|
11278
|
-
throw new TypeError(`Invalid http version string (${value})`);
|
|
11279
|
-
this.httpVersionMajor = parseInt(m[1], 10);
|
|
11280
|
-
this.httpVersionMinor = parseInt(m[2], 10);
|
|
11281
|
-
} else {
|
|
11282
|
-
this.httpVersionMajor = void 0;
|
|
11283
|
-
this.httpVersionMinor = void 0;
|
|
11284
|
-
}
|
|
11285
|
-
}
|
|
11286
|
-
get headers() {
|
|
11287
|
-
this._initHeaders();
|
|
11288
|
-
return this[kHeadersProxy];
|
|
11289
|
-
}
|
|
11290
|
-
set headers(headers) {
|
|
11291
|
-
this[kHeaders].clear();
|
|
11292
|
-
this[kHeaders].set(headers);
|
|
11293
|
-
}
|
|
11294
|
-
get trailers() {
|
|
11295
|
-
this._initTrailers();
|
|
11296
|
-
return this[kTrailersProxy];
|
|
11297
|
-
}
|
|
11298
|
-
set trailers(trailers) {
|
|
11299
|
-
this[kTrailers].clear();
|
|
11300
|
-
this[kTrailers].set(trailers);
|
|
11301
|
-
}
|
|
11302
|
-
get rawHeaders() {
|
|
11303
|
-
this._buildRawHeaders();
|
|
11304
|
-
return this._rawHeaders;
|
|
11305
|
-
}
|
|
11306
|
-
set rawHeaders(headers) {
|
|
11307
|
-
this[kHeadersProxy] = void 0;
|
|
11308
|
-
this._headersChanged = false;
|
|
11309
|
-
this._rawHeaders = headers;
|
|
11310
|
-
}
|
|
11311
|
-
get rawTrailers() {
|
|
11312
|
-
this._buildRawTrailers();
|
|
11313
|
-
return this._rawTrailers;
|
|
11314
|
-
}
|
|
11315
|
-
set rawTrailers(trailers) {
|
|
11316
|
-
this[kTrailersProxy] = void 0;
|
|
11317
|
-
this._trailersChanged = false;
|
|
11318
|
-
this._rawTrailers = trailers;
|
|
11319
|
-
}
|
|
11320
|
-
getHeader(name) {
|
|
11321
|
-
if (!name)
|
|
11322
|
-
return;
|
|
11323
|
-
this._initHeaders();
|
|
11324
|
-
switch (name.toLowerCase()) {
|
|
11325
|
-
case "referer":
|
|
11326
|
-
case "referrer":
|
|
11327
|
-
return this[kHeaders].get(name) || this[kHeaders].get("referrer") || this[kHeaders].get("referer");
|
|
11328
|
-
default:
|
|
11329
|
-
return this[kHeaders].get(name);
|
|
11330
|
-
}
|
|
11331
|
-
}
|
|
11332
|
-
get(name) {
|
|
11333
|
-
this._initHeaders();
|
|
11334
|
-
return this[kHeaders].get(name);
|
|
11335
|
-
}
|
|
11336
|
-
setHeader(arg0, arg1) {
|
|
11337
|
-
this._initHeaders();
|
|
11338
|
-
if (typeof arg0 === "object")
|
|
11339
|
-
this[kHeaders].set(arg0);
|
|
11340
|
-
else
|
|
11341
|
-
this[kHeaders].set(arg0, arg1);
|
|
11342
|
-
return this;
|
|
11343
|
-
}
|
|
11344
|
-
set(arg0, arg1) {
|
|
11345
|
-
return this.setHeader(arg0, arg1);
|
|
11346
|
-
}
|
|
11347
|
-
getHeaders() {
|
|
11348
|
-
this._initHeaders();
|
|
11349
|
-
return this[kHeaders].toObject();
|
|
11350
|
-
}
|
|
11351
|
-
getHeaderNames() {
|
|
11352
|
-
this._initHeaders();
|
|
11353
|
-
return Array.from(this[kHeaders].keys());
|
|
11354
|
-
}
|
|
11355
|
-
hasHeader(name) {
|
|
11356
|
-
this._initHeaders();
|
|
11357
|
-
return this[kHeaders].has(name);
|
|
11358
|
-
}
|
|
11359
|
-
removeHeader(name) {
|
|
11360
|
-
this._initHeaders();
|
|
11361
|
-
this[kHeaders].delete(name);
|
|
11362
|
-
}
|
|
11363
|
-
send(body) {
|
|
11364
|
-
this.body = body;
|
|
11365
|
-
return this;
|
|
11366
|
-
}
|
|
11367
|
-
end(body) {
|
|
11368
|
-
if (body)
|
|
11369
|
-
this.body = body;
|
|
11370
|
-
return this;
|
|
11371
|
-
}
|
|
11372
|
-
setTimeout() {
|
|
11373
|
-
return this;
|
|
11374
|
-
}
|
|
11375
|
-
_init(args) {
|
|
11376
|
-
this.complete = true;
|
|
11377
|
-
this.httpVersionMajor = args?.httpVersionMajor;
|
|
11378
|
-
this.httpVersionMinor = args?.httpVersionMinor;
|
|
11379
|
-
this._rawHeaders = args.rawHeaders;
|
|
11380
|
-
this._rawTrailers = args.rawTrailers;
|
|
11381
|
-
if (args.headers)
|
|
11382
|
-
this[kHeaders].set(args.headers);
|
|
11383
|
-
if (args.trailers)
|
|
11384
|
-
this[kTrailers].set(args.trailers);
|
|
11385
|
-
this.body = args.body;
|
|
11386
|
-
}
|
|
11387
|
-
_parseBuffer(buf, parserType) {
|
|
11388
|
-
const parser = new HTTPParser(parserType);
|
|
11389
|
-
parser[HTTPParser.kOnHeadersComplete] = this[kOnHeaderReceived].bind(this);
|
|
11390
|
-
parser[HTTPParser.kOnBody] = this[kOnBodyChunk].bind(this);
|
|
11391
|
-
parser[HTTPParser.kOnHeaders] = this[kOnTrailersReceived].bind(this);
|
|
11392
|
-
parser[HTTPParser.kOnMessageComplete] = this[kOnReadComplete].bind(this);
|
|
11393
|
-
const buffer = Buffer.from(buf);
|
|
11394
|
-
let x = parser.execute(buffer);
|
|
11395
|
-
if (typeof x === "object")
|
|
11396
|
-
throw x;
|
|
11397
|
-
if (!this.complete) {
|
|
11398
|
-
x = parser.execute(crlfBuffer);
|
|
11399
|
-
if (typeof x === "object")
|
|
11400
|
-
throw x;
|
|
11401
|
-
}
|
|
11402
|
-
parser.finish();
|
|
11403
|
-
}
|
|
11404
|
-
_initHeaders() {
|
|
11405
|
-
if (!this[kHeadersProxy]) {
|
|
11406
|
-
this[kHeadersProxy] = this[kHeaders].getProxy();
|
|
11407
|
-
if (this._rawHeaders) {
|
|
11408
|
-
const src = this._rawHeaders;
|
|
11409
|
-
const l = Math.floor(src.length / 2);
|
|
11410
|
-
for (let n = 0; n <= l; n += 2) {
|
|
11411
|
-
this[kHeaders].append(src[n], src[n + 1]);
|
|
11412
|
-
}
|
|
11413
|
-
}
|
|
11414
|
-
}
|
|
11415
|
-
}
|
|
11416
|
-
_initTrailers() {
|
|
11417
|
-
if (!this[kTrailersProxy]) {
|
|
11418
|
-
this[kTrailersProxy] = this[kTrailers].getProxy();
|
|
11419
|
-
if (this._rawTrailers) {
|
|
11420
|
-
const src = this._rawTrailers;
|
|
11421
|
-
const l = Math.floor(src.length / 2);
|
|
11422
|
-
for (let n = 0; n <= l; n += 2) {
|
|
11423
|
-
this[kTrailers].append(src[n], src[n + 1]);
|
|
11424
|
-
}
|
|
11425
|
-
}
|
|
11426
|
-
}
|
|
11427
|
-
}
|
|
11428
|
-
_buildRawHeaders() {
|
|
11429
|
-
if (this._headersChanged || !this._rawHeaders) {
|
|
11430
|
-
this._headersChanged = false;
|
|
11431
|
-
this._rawHeaders = Object.entries(this.headers).reduce((a, [k, v]) => {
|
|
11432
|
-
if (Array.isArray(v))
|
|
11433
|
-
v.forEach((x) => a.push(k, String(x)));
|
|
11434
|
-
else
|
|
11435
|
-
a.push(k, String(v));
|
|
11436
|
-
return a;
|
|
11437
|
-
}, []);
|
|
11438
|
-
}
|
|
11439
|
-
}
|
|
11440
|
-
_buildRawTrailers() {
|
|
11441
|
-
if (this._trailersChanged || !this._rawTrailers) {
|
|
11442
|
-
this._trailersChanged = false;
|
|
11443
|
-
this._rawTrailers = Object.entries(this.trailers).reduce((a, [k, v]) => {
|
|
11444
|
-
if (Array.isArray(v))
|
|
11445
|
-
v.forEach((x) => a.push(k, String(x)));
|
|
11446
|
-
else
|
|
11447
|
-
a.push(k, String(v));
|
|
11448
|
-
return a;
|
|
11449
|
-
}, []);
|
|
11450
|
-
}
|
|
11451
|
-
}
|
|
11452
|
-
[kOnHeaderReceived](info) {
|
|
11453
|
-
this.httpVersionMajor = info.versionMajor;
|
|
11454
|
-
this.httpVersionMinor = info.versionMinor;
|
|
11455
|
-
this._rawHeaders = info.headers;
|
|
11456
|
-
this.shouldKeepAlive = info.shouldKeepAlive;
|
|
11457
|
-
this.upgrade = info.upgrade;
|
|
11458
|
-
}
|
|
11459
|
-
[kOnTrailersReceived](trailers) {
|
|
11460
|
-
this._rawTrailers = trailers;
|
|
11461
|
-
}
|
|
11462
|
-
[kOnBodyChunk](chunk, offset, length) {
|
|
11463
|
-
this._bodyChunks = this._bodyChunks || [];
|
|
11464
|
-
this._bodyChunks.push(chunk.subarray(offset, offset + length));
|
|
11465
|
-
}
|
|
11466
|
-
[kOnReadComplete]() {
|
|
11467
|
-
this.complete = true;
|
|
11468
|
-
if (this._bodyChunks) {
|
|
11469
|
-
this.body = Buffer.concat(this._bodyChunks);
|
|
11470
|
-
this._bodyChunks = void 0;
|
|
11471
|
-
}
|
|
11472
|
-
}
|
|
11473
|
-
};
|
|
11474
|
-
HttpMessageHost.kHeaders = kHeaders;
|
|
11475
|
-
HttpMessageHost.kHeadersProxy = kHeadersProxy;
|
|
11476
|
-
HttpMessageHost.kTrailers = kTrailers;
|
|
11477
|
-
HttpMessageHost.kTrailersProxy = kTrailersProxy;
|
|
11478
|
-
HttpMessageHost.kOnHeaderReceived = kOnHeaderReceived;
|
|
11479
|
-
HttpMessageHost.kOnTrailersReceived = kOnTrailersReceived;
|
|
11480
|
-
HttpMessageHost.kOnBodyChunk = kOnBodyChunk;
|
|
11481
|
-
HttpMessageHost.kOnReadComplete = kOnReadComplete;
|
|
11482
|
-
Object.assign(HttpMessageHost.prototype, stream.Duplex.prototype);
|
|
11483
|
-
|
|
11484
|
-
// ../../build/common/esm/http/http-response-message.js
|
|
11485
|
-
var HttpResponseMessage;
|
|
11486
|
-
/* @__PURE__ */ (function(HttpResponseMessage2) {
|
|
11487
|
-
function create(init) {
|
|
11488
|
-
return HttpResponseMessageHost.create(init);
|
|
11489
|
-
}
|
|
11490
|
-
__name(create, "create");
|
|
11491
|
-
HttpResponseMessage2.create = create;
|
|
11492
|
-
function fromBuffer(buffer) {
|
|
11493
|
-
return HttpResponseMessageHost.fromBuffer(buffer);
|
|
11494
|
-
}
|
|
11495
|
-
__name(fromBuffer, "fromBuffer");
|
|
11496
|
-
HttpResponseMessage2.fromBuffer = fromBuffer;
|
|
11497
|
-
async function fromStream(readable) {
|
|
11498
|
-
return HttpResponseMessageHost.fromStream(readable);
|
|
11499
|
-
}
|
|
11500
|
-
__name(fromStream, "fromStream");
|
|
11501
|
-
HttpResponseMessage2.fromStream = fromStream;
|
|
11502
|
-
})(HttpResponseMessage || (HttpResponseMessage = {}));
|
|
11503
|
-
var HttpResponseMessageHost = class _HttpResponseMessageHost extends HttpMessageHost {
|
|
11504
|
-
static {
|
|
11505
|
-
__name(this, "HttpResponseMessageHost");
|
|
11506
|
-
}
|
|
11507
|
-
constructor() {
|
|
11508
|
-
super();
|
|
11509
|
-
}
|
|
11510
|
-
header(arg0, arg1) {
|
|
11511
|
-
return this.set(arg0, arg1);
|
|
11512
|
-
}
|
|
11513
|
-
append(name, value) {
|
|
11514
|
-
this[HttpMessageHost.kHeaders].append(name, value);
|
|
11515
|
-
return this;
|
|
11516
|
-
}
|
|
11517
|
-
/**
|
|
11518
|
-
* Set "Content-Disposition" header to "attachment" with optional `filename`.
|
|
11519
|
-
*/
|
|
11520
|
-
attachment(filename) {
|
|
11521
|
-
if (filename)
|
|
11522
|
-
this.type(path2.extname(filename));
|
|
11523
|
-
this.set("Content-Disposition", contentDisposition(filename));
|
|
11524
|
-
return this;
|
|
11525
|
-
}
|
|
11526
|
-
/**
|
|
11527
|
-
* Alias for msg.type()
|
|
11528
|
-
*/
|
|
11529
|
-
contentType(type) {
|
|
11530
|
-
return this.type(type);
|
|
11531
|
-
}
|
|
11532
|
-
/**
|
|
11533
|
-
* Set _Content-Type_ response header with `type` through `mime.lookup()`
|
|
11534
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
11535
|
-
*
|
|
11536
|
-
* Examples:
|
|
11537
|
-
*
|
|
11538
|
-
* res.type('.html');
|
|
11539
|
-
* res.type('html');
|
|
11540
|
-
* res.type('json');
|
|
11541
|
-
* res.type('application/json');
|
|
11542
|
-
* res.type('png');
|
|
11543
|
-
*/
|
|
11544
|
-
type(type) {
|
|
11545
|
-
const ct = type.indexOf("/") === -1 ? mime.lookup(type) : type;
|
|
11546
|
-
if (ct)
|
|
11547
|
-
this.set("Content-Type", ct);
|
|
11548
|
-
return this;
|
|
11549
|
-
}
|
|
11550
|
-
/**
|
|
11551
|
-
* Set cookie `name` to `value`, with the given `options`.
|
|
11552
|
-
*
|
|
11553
|
-
* Options:
|
|
11554
|
-
*
|
|
11555
|
-
* - `maxAge` max-age in milliseconds, converted to `expires`
|
|
11556
|
-
* - `signed` sign the cookie
|
|
11557
|
-
* - `path` defaults to "/"
|
|
11558
|
-
*
|
|
11559
|
-
* Examples:
|
|
11560
|
-
*
|
|
11561
|
-
* // "Remember Me" for 15 minutes
|
|
11562
|
-
* res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
|
|
11563
|
-
*
|
|
11564
|
-
* // same as above
|
|
11565
|
-
* res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
|
|
11566
|
-
*
|
|
11567
|
-
*/
|
|
11568
|
-
cookie(name, value, options) {
|
|
11569
|
-
const opts = { ...options };
|
|
11570
|
-
const secret = this.req?.secret;
|
|
11571
|
-
const signed = opts.signed;
|
|
11572
|
-
if (signed && !secret) {
|
|
11573
|
-
throw new Error('cookieParser("secret") required for signed cookies');
|
|
11574
|
-
}
|
|
11575
|
-
let val = typeof value === "object" ? "j:" + JSON.stringify(value) : String(value);
|
|
11576
|
-
if (signed)
|
|
11577
|
-
val = "s:" + cookieSignature.sign(val, secret);
|
|
11578
|
-
if (opts.maxAge != null) {
|
|
11579
|
-
const maxAge = opts.maxAge - 0;
|
|
11580
|
-
if (!isNaN(maxAge)) {
|
|
11581
|
-
opts.expires = new Date(Date.now() + maxAge);
|
|
11582
|
-
opts.maxAge = Math.floor(maxAge / 1e3);
|
|
11583
|
-
}
|
|
11584
|
-
}
|
|
11585
|
-
if (opts.path == null)
|
|
11586
|
-
opts.path = "/";
|
|
11587
|
-
let a = this.get("Set-Cookie");
|
|
11588
|
-
if (a && Array.isArray(a)) {
|
|
11589
|
-
a = a.filter((x) => !x.startsWith(name + "="));
|
|
11590
|
-
this.set("Set-Cookie", a);
|
|
11591
|
-
}
|
|
11592
|
-
this.append("Set-Cookie", cookie.serialize(name, String(val), opts));
|
|
11593
|
-
return this;
|
|
11594
|
-
}
|
|
11595
|
-
/**
|
|
11596
|
-
* Clear cookie `name`.
|
|
11597
|
-
*/
|
|
11598
|
-
clearCookie(name, options) {
|
|
11599
|
-
return this.cookie(name, "", { expires: /* @__PURE__ */ new Date(1), path: "/", ...options });
|
|
11600
|
-
}
|
|
11601
|
-
/**
|
|
11602
|
-
* Set Link header field with the given `links`.
|
|
11603
|
-
*
|
|
11604
|
-
* Examples:
|
|
11605
|
-
*
|
|
11606
|
-
* res.links({
|
|
11607
|
-
* next: 'http://api.example.com/users?page=2',
|
|
11608
|
-
* last: 'http://api.example.com/users?page=5'
|
|
11609
|
-
* });
|
|
11610
|
-
*
|
|
11611
|
-
*/
|
|
11612
|
-
links(links) {
|
|
11613
|
-
let link = this.get("Link") || "";
|
|
11614
|
-
if (link)
|
|
11615
|
-
link += ", ";
|
|
11616
|
-
return this.set("Link", link + Object.keys(links).map((rel) => "<" + links[rel] + '>; rel="' + rel + '"').join(", "));
|
|
11617
|
-
}
|
|
11618
|
-
redirect(arg0, url) {
|
|
11619
|
-
let status = 302;
|
|
11620
|
-
if (typeof arg0 === "number") {
|
|
11621
|
-
status = arg0;
|
|
11622
|
-
} else
|
|
11623
|
-
url = arg0 || "";
|
|
11624
|
-
this.location(url || "/");
|
|
11625
|
-
this.statusCode = status;
|
|
11626
|
-
}
|
|
11627
|
-
/**
|
|
11628
|
-
* Send JSON response.
|
|
11629
|
-
*
|
|
11630
|
-
* Examples:
|
|
11631
|
-
*
|
|
11632
|
-
* res.json(null);
|
|
11633
|
-
* res.json({ user: 'tj' });
|
|
11634
|
-
*/
|
|
11635
|
-
json(obj) {
|
|
11636
|
-
if (!this.get("Content-Type"))
|
|
11637
|
-
this.set("Content-Type", "application/json");
|
|
11638
|
-
const body = JSON.stringify(obj);
|
|
11639
|
-
return this.send(body);
|
|
11640
|
-
}
|
|
11641
|
-
location(url) {
|
|
11642
|
-
let loc = url;
|
|
11643
|
-
if (url === "back")
|
|
11644
|
-
loc = this.req?.get("Referrer") || "/";
|
|
11645
|
-
return this.set("Location", encodeUrl(loc));
|
|
11646
|
-
}
|
|
11647
|
-
/**
|
|
11648
|
-
* Set status `code`.
|
|
11649
|
-
*/
|
|
11650
|
-
status(code) {
|
|
11651
|
-
this.statusCode = code;
|
|
11652
|
-
return this;
|
|
11653
|
-
}
|
|
11654
|
-
/**
|
|
11655
|
-
* Set the response HTTP status code to `statusCode` and send its string representation as the response body.
|
|
11656
|
-
* @link http://expressjs.com/4x/api.html#res.sendStatus
|
|
11657
|
-
*
|
|
11658
|
-
* Examples:
|
|
11659
|
-
*
|
|
11660
|
-
* res.sendStatus(200); // equivalent to res.status(200).send('OK')
|
|
11661
|
-
* res.sendStatus(403); // equivalent to res.status(403).send('Forbidden')
|
|
11662
|
-
* res.sendStatus(404); // equivalent to res.status(404).send('Not Found')
|
|
11663
|
-
* res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
|
|
11664
|
-
*/
|
|
11665
|
-
sendStatus(statusCode) {
|
|
11666
|
-
const body = HttpStatusMessages[statusCode] || String(statusCode);
|
|
11667
|
-
this.statusCode = statusCode;
|
|
11668
|
-
this.type("txt");
|
|
11669
|
-
return this.send(body);
|
|
11670
|
-
}
|
|
11671
|
-
_init(init) {
|
|
11672
|
-
super._init(init);
|
|
11673
|
-
this.statusCode = init?.statusCode;
|
|
11674
|
-
this.statusMessage = init?.statusMessage;
|
|
11675
|
-
this.req = init?.req;
|
|
11676
|
-
this.chunkedEncoding = init?.chunkedEncoding;
|
|
11677
|
-
}
|
|
11678
|
-
[HttpMessageHost.kOnHeaderReceived](info) {
|
|
11679
|
-
super[HttpMessageHost.kOnHeaderReceived](info);
|
|
11680
|
-
this.statusCode = info.statusCode;
|
|
11681
|
-
this.statusMessage = info.statusMessage;
|
|
11682
|
-
}
|
|
11683
|
-
static create(init) {
|
|
11684
|
-
const msg = new _HttpResponseMessageHost();
|
|
11685
|
-
msg._init(init);
|
|
11686
|
-
return msg;
|
|
11687
|
-
}
|
|
11688
|
-
static fromBuffer(buffer) {
|
|
11689
|
-
const msg = new _HttpResponseMessageHost();
|
|
11690
|
-
msg._parseBuffer(buffer, HTTPParser2.RESPONSE);
|
|
11691
|
-
return msg;
|
|
11692
|
-
}
|
|
11693
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11694
|
-
static async fromStream(readable) {
|
|
11695
|
-
throw new Error("fromStream is not implemented yet");
|
|
11696
|
-
}
|
|
11697
|
-
};
|
|
11698
|
-
|
|
11699
|
-
// ../../build/common/esm/http/http-request-message.js
|
|
11700
|
-
import accepts from "accepts";
|
|
11701
|
-
import typeIs from "type-is";
|
|
11702
|
-
import { HTTPParser as HTTPParser3 } from "@browsery/http-parser";
|
|
11703
|
-
var HTTP_VERSION_PATTERN2 = /^(\d)\.(\d)$/;
|
|
11704
|
-
var HttpRequestMessage;
|
|
11705
|
-
/* @__PURE__ */ (function(HttpRequestMessage2) {
|
|
11706
|
-
function create(init) {
|
|
11707
|
-
return HttpRequestMessageHost.create(init);
|
|
11708
|
-
}
|
|
11709
|
-
__name(create, "create");
|
|
11710
|
-
HttpRequestMessage2.create = create;
|
|
11711
|
-
function fromBuffer(buffer) {
|
|
11712
|
-
return HttpRequestMessageHost.fromBuffer(buffer);
|
|
11713
|
-
}
|
|
11714
|
-
__name(fromBuffer, "fromBuffer");
|
|
11715
|
-
HttpRequestMessage2.fromBuffer = fromBuffer;
|
|
11716
|
-
async function fromStream(readable) {
|
|
11717
|
-
return HttpRequestMessageHost.fromStream(readable);
|
|
11718
|
-
}
|
|
11719
|
-
__name(fromStream, "fromStream");
|
|
11720
|
-
HttpRequestMessage2.fromStream = fromStream;
|
|
11721
|
-
})(HttpRequestMessage || (HttpRequestMessage = {}));
|
|
11722
|
-
var kQuery = Symbol("kQuery");
|
|
11723
|
-
var kQueryProxy = Symbol("kQueryProxy");
|
|
11724
|
-
var kProtocol = Symbol("kProtocol");
|
|
11725
|
-
var HttpRequestMessageHost = class _HttpRequestMessageHost extends HttpMessageHost {
|
|
11726
|
-
static {
|
|
11727
|
-
__name(this, "HttpRequestMessageHost");
|
|
11728
|
-
}
|
|
11729
|
-
constructor() {
|
|
11730
|
-
super();
|
|
11731
|
-
this.httpVersionMajor = 1;
|
|
11732
|
-
this.httpVersionMinor = 0;
|
|
11733
|
-
this[kQuery] = new HttpParams();
|
|
11734
|
-
this[kQueryProxy] = this[kQuery].getProxy();
|
|
11735
|
-
}
|
|
11736
|
-
get httpVersion() {
|
|
11737
|
-
return this.httpVersionMajor + "." + this.httpVersionMinor;
|
|
11738
|
-
}
|
|
11739
|
-
set httpVersion(value) {
|
|
11740
|
-
const m = HTTP_VERSION_PATTERN2.exec(value);
|
|
11741
|
-
if (!m)
|
|
11742
|
-
throw new TypeError(`Invalid http version string (${value})`);
|
|
11743
|
-
this.httpVersionMajor = parseInt(m[1], 10);
|
|
11744
|
-
this.httpVersionMinor = parseInt(m[2], 10);
|
|
11745
|
-
}
|
|
11746
|
-
get hostname() {
|
|
11747
|
-
let host = this.get("X-Forwarded-Host") || this.get("Host");
|
|
11748
|
-
if (host && host.indexOf(",") !== -1) {
|
|
11749
|
-
host = host.substring(0, host.indexOf(",")).trimEnd();
|
|
11750
|
-
}
|
|
11751
|
-
if (!host)
|
|
11752
|
-
return "";
|
|
11753
|
-
const offset = host[0] === "[" ? host.indexOf("]") + 1 : 0;
|
|
11754
|
-
const index = host.indexOf(":", offset);
|
|
11755
|
-
return index !== -1 ? host.substring(0, index) : host;
|
|
11756
|
-
}
|
|
11757
|
-
get protocol() {
|
|
11758
|
-
if (this[kProtocol])
|
|
11759
|
-
return this[kProtocol];
|
|
11760
|
-
const header = this.get("X-Forwarded-Proto");
|
|
11761
|
-
if (header) {
|
|
11762
|
-
const index = header.indexOf(",");
|
|
11763
|
-
return index !== -1 ? header.substring(0, index).trim() : header.trim();
|
|
11764
|
-
}
|
|
11765
|
-
return "http";
|
|
11766
|
-
}
|
|
11767
|
-
set protocol(v) {
|
|
11768
|
-
this[kProtocol] = v;
|
|
11769
|
-
}
|
|
11770
|
-
get secure() {
|
|
11771
|
-
return this.protocol === "https";
|
|
11772
|
-
}
|
|
11773
|
-
get query() {
|
|
11774
|
-
return this[kQueryProxy];
|
|
11775
|
-
}
|
|
11776
|
-
set query(value) {
|
|
11777
|
-
this[kQuery].clear();
|
|
11778
|
-
this[kQuery].appendAll(value);
|
|
11779
|
-
}
|
|
11780
|
-
header(name) {
|
|
11781
|
-
return this.getHeader(name);
|
|
11782
|
-
}
|
|
11783
|
-
accepts(...type) {
|
|
11784
|
-
const accept = accepts(this);
|
|
11785
|
-
return accept.types.apply(accept, type);
|
|
11786
|
-
}
|
|
11787
|
-
acceptsCharsets(...charset) {
|
|
11788
|
-
const accept = accepts(this);
|
|
11789
|
-
return accept.charsets.apply(accept, charset);
|
|
11790
|
-
}
|
|
11791
|
-
acceptsEncodings(...encoding) {
|
|
11792
|
-
const accept = accepts(this);
|
|
11793
|
-
return accept.encodings.apply(accept, encoding);
|
|
11794
|
-
}
|
|
11795
|
-
acceptsLanguages(...lang) {
|
|
11796
|
-
const accept = accepts(this);
|
|
11797
|
-
return accept.languages.apply(accept, lang);
|
|
11798
|
-
}
|
|
11799
|
-
is(type, ...otherTypes) {
|
|
11800
|
-
const types = Array.isArray(type) ? type : [type];
|
|
11801
|
-
if (otherTypes.length)
|
|
11802
|
-
types.push(...otherTypes);
|
|
11803
|
-
const contentType = this.getHeader("content-type");
|
|
11804
|
-
return contentType ? typeIs.is(contentType, types) : null;
|
|
11805
|
-
}
|
|
11806
|
-
_init(init) {
|
|
11807
|
-
super._init(init);
|
|
11808
|
-
this.method = init.method.toUpperCase();
|
|
11809
|
-
this.url = init.url;
|
|
11810
|
-
this.baseUrl = init.baseUrl || this.url;
|
|
11811
|
-
this.protocol = init.protocol;
|
|
11812
|
-
}
|
|
11813
|
-
[HttpMessageHost.kOnHeaderReceived](info) {
|
|
11814
|
-
super[HttpMessageHost.kOnHeaderReceived](info);
|
|
11815
|
-
this.method = HTTPParser3.methods[info.method];
|
|
11816
|
-
this.url = info.url;
|
|
11817
|
-
this.baseUrl = info.url;
|
|
11818
|
-
}
|
|
11819
|
-
static create(init) {
|
|
11820
|
-
const msg = new _HttpRequestMessageHost();
|
|
11821
|
-
msg._init(init);
|
|
11822
|
-
return msg;
|
|
11823
|
-
}
|
|
11824
|
-
static fromBuffer(buffer) {
|
|
11825
|
-
const msg = new _HttpRequestMessageHost();
|
|
11826
|
-
msg._parseBuffer(buffer, HTTPParser3.REQUEST);
|
|
11827
|
-
return msg;
|
|
11828
|
-
}
|
|
11829
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11830
|
-
static async fromStream(readable) {
|
|
11831
|
-
throw new Error("fromStream is not implemented yet");
|
|
11832
|
-
}
|
|
11833
|
-
};
|
|
11834
|
-
HttpRequestMessageHost.kQuery = kQuery;
|
|
11835
|
-
|
|
11836
|
-
// ../../build/common/esm/http/enums/http-status-codes.enum.js
|
|
11837
|
-
var HttpStatusCodes;
|
|
11838
|
-
(function(HttpStatusCodes2) {
|
|
11839
|
-
HttpStatusCodes2[HttpStatusCodes2["CONTINUE"] = 100] = "CONTINUE";
|
|
11840
|
-
HttpStatusCodes2[HttpStatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
11841
|
-
HttpStatusCodes2[HttpStatusCodes2["PROCESSING"] = 102] = "PROCESSING";
|
|
11842
|
-
HttpStatusCodes2[HttpStatusCodes2["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
11843
|
-
HttpStatusCodes2[HttpStatusCodes2["OK"] = 200] = "OK";
|
|
11844
|
-
HttpStatusCodes2[HttpStatusCodes2["CREATED"] = 201] = "CREATED";
|
|
11845
|
-
HttpStatusCodes2[HttpStatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
11846
|
-
HttpStatusCodes2[HttpStatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
11847
|
-
HttpStatusCodes2[HttpStatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
11848
|
-
HttpStatusCodes2[HttpStatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
11849
|
-
HttpStatusCodes2[HttpStatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
11850
|
-
HttpStatusCodes2[HttpStatusCodes2["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
11851
|
-
HttpStatusCodes2[HttpStatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
11852
|
-
HttpStatusCodes2[HttpStatusCodes2["FOUND"] = 302] = "FOUND";
|
|
11853
|
-
HttpStatusCodes2[HttpStatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
11854
|
-
HttpStatusCodes2[HttpStatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
11855
|
-
HttpStatusCodes2[HttpStatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
11856
|
-
HttpStatusCodes2[HttpStatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
11857
|
-
HttpStatusCodes2[HttpStatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
11858
|
-
HttpStatusCodes2[HttpStatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
11859
|
-
HttpStatusCodes2[HttpStatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
11860
|
-
HttpStatusCodes2[HttpStatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
11861
|
-
HttpStatusCodes2[HttpStatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
11862
|
-
HttpStatusCodes2[HttpStatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
11863
|
-
HttpStatusCodes2[HttpStatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
11864
|
-
HttpStatusCodes2[HttpStatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
11865
|
-
HttpStatusCodes2[HttpStatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
11866
|
-
HttpStatusCodes2[HttpStatusCodes2["CONFLICT"] = 409] = "CONFLICT";
|
|
11867
|
-
HttpStatusCodes2[HttpStatusCodes2["GONE"] = 410] = "GONE";
|
|
11868
|
-
HttpStatusCodes2[HttpStatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
11869
|
-
HttpStatusCodes2[HttpStatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
11870
|
-
HttpStatusCodes2[HttpStatusCodes2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
11871
|
-
HttpStatusCodes2[HttpStatusCodes2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
11872
|
-
HttpStatusCodes2[HttpStatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
11873
|
-
HttpStatusCodes2[HttpStatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
11874
|
-
HttpStatusCodes2[HttpStatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
11875
|
-
HttpStatusCodes2[HttpStatusCodes2["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
11876
|
-
HttpStatusCodes2[HttpStatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
11877
|
-
HttpStatusCodes2[HttpStatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
11878
|
-
HttpStatusCodes2[HttpStatusCodes2["LOCKED"] = 423] = "LOCKED";
|
|
11879
|
-
HttpStatusCodes2[HttpStatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
11880
|
-
HttpStatusCodes2[HttpStatusCodes2["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
11881
|
-
HttpStatusCodes2[HttpStatusCodes2["UPGRADE_REQUIRED"] = 428] = "UPGRADE_REQUIRED";
|
|
11882
|
-
HttpStatusCodes2[HttpStatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
11883
|
-
HttpStatusCodes2[HttpStatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
11884
|
-
HttpStatusCodes2[HttpStatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
11885
|
-
HttpStatusCodes2[HttpStatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
11886
|
-
HttpStatusCodes2[HttpStatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
11887
|
-
HttpStatusCodes2[HttpStatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
11888
|
-
HttpStatusCodes2[HttpStatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
11889
|
-
HttpStatusCodes2[HttpStatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
11890
|
-
HttpStatusCodes2[HttpStatusCodes2["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
11891
|
-
HttpStatusCodes2[HttpStatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
11892
|
-
HttpStatusCodes2[HttpStatusCodes2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
11893
|
-
HttpStatusCodes2[HttpStatusCodes2["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
11894
|
-
HttpStatusCodes2[HttpStatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
11895
|
-
})(HttpStatusCodes || (HttpStatusCodes = {}));
|
|
11896
|
-
|
|
11897
11333
|
// ../../build/common/esm/url/opra-url.js
|
|
11898
11334
|
import { splitString as splitString4, tokenize as tokenize4 } from "fast-tokenizer";
|
|
11899
11335
|
|
|
@@ -12473,10 +11909,8 @@ export {
|
|
|
12473
11909
|
HttpHeaderCodes,
|
|
12474
11910
|
HttpHeaders,
|
|
12475
11911
|
HttpParams,
|
|
12476
|
-
HttpRequestMessage,
|
|
12477
|
-
HttpResponseMessage,
|
|
12478
|
-
HttpResponseMessageHost,
|
|
12479
11912
|
HttpStatusCodes,
|
|
11913
|
+
HttpStatusMessages,
|
|
12480
11914
|
I18n,
|
|
12481
11915
|
IntegerCodec,
|
|
12482
11916
|
InternalServerError,
|