@comunica/actor-http-native 3.3.0 → 4.0.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/README.md +1 -1
- package/components/ActorHttpNative.jsonld +44 -16
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +7 -1
- package/lib/ActorHttpNative.d.ts +3 -4
- package/lib/ActorHttpNative.js +7 -11
- package/lib/ActorHttpNative.js.map +1 -1
- package/lib/Requester-browser.js +0 -2
- package/lib/Requester-browser.js.map +1 -1
- package/lib/Requester.d.ts +0 -1
- package/lib/Requester.js +0 -1
- package/lib/Requester.js.map +1 -1
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
25
25
|
{
|
|
26
26
|
"@context": [
|
|
27
27
|
...
|
|
28
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-native/^
|
|
28
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-native/^4.0.0/components/context.jsonld"
|
|
29
29
|
],
|
|
30
30
|
"actors": [
|
|
31
31
|
...
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-native/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-http/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-native/^4.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-http/^4.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^4.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-http-native",
|
|
8
8
|
"components": [
|
|
@@ -55,29 +55,37 @@
|
|
|
55
55
|
"genericTypeInstances": [
|
|
56
56
|
{
|
|
57
57
|
"@type": "ParameterRangeGenericTypeReference",
|
|
58
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
58
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"@type": "ParameterRangeGenericTypeReference",
|
|
62
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
62
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"@type": "ParameterRangeGenericTypeReference",
|
|
66
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
66
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
70
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
67
71
|
}
|
|
68
72
|
]
|
|
69
73
|
},
|
|
70
74
|
{
|
|
71
75
|
"@type": "ParameterRangeGenericTypeReference",
|
|
72
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
76
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
73
77
|
},
|
|
74
78
|
{
|
|
75
79
|
"@type": "ParameterRangeGenericTypeReference",
|
|
76
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
80
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
77
81
|
},
|
|
78
82
|
{
|
|
79
83
|
"@type": "ParameterRangeGenericTypeReference",
|
|
80
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
84
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
88
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
81
89
|
}
|
|
82
90
|
]
|
|
83
91
|
},
|
|
@@ -87,6 +95,20 @@
|
|
|
87
95
|
},
|
|
88
96
|
"comment": "The bus this actor subscribes to."
|
|
89
97
|
},
|
|
98
|
+
{
|
|
99
|
+
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_busFailMessage",
|
|
100
|
+
"range": {
|
|
101
|
+
"@type": "ParameterRangeUnion",
|
|
102
|
+
"parameterRangeElements": [
|
|
103
|
+
"xsd:string",
|
|
104
|
+
{
|
|
105
|
+
"@type": "ParameterRangeUndefined"
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"default": "HTTP request failed: none of the configured actors were able to handle ${action.input}",
|
|
110
|
+
"comment": "The message that will be configured in the bus for reporting failures. This message may be a template string that contains references to the executed `action`. For example, the following templated string is allowed: \"RDF dereferencing failed: no actors could handle ${action.handle.mediaType}\""
|
|
111
|
+
},
|
|
90
112
|
{
|
|
91
113
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_beforeActors",
|
|
92
114
|
"range": {
|
|
@@ -100,15 +122,19 @@
|
|
|
100
122
|
"genericTypeInstances": [
|
|
101
123
|
{
|
|
102
124
|
"@type": "ParameterRangeGenericTypeReference",
|
|
103
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
125
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
129
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
104
130
|
},
|
|
105
131
|
{
|
|
106
132
|
"@type": "ParameterRangeGenericTypeReference",
|
|
107
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
133
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
108
134
|
},
|
|
109
135
|
{
|
|
110
136
|
"@type": "ParameterRangeGenericTypeReference",
|
|
111
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
137
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
112
138
|
}
|
|
113
139
|
]
|
|
114
140
|
}
|
|
@@ -134,10 +160,6 @@
|
|
|
134
160
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative__member_constructor",
|
|
135
161
|
"memberFieldName": "constructor"
|
|
136
162
|
},
|
|
137
|
-
{
|
|
138
|
-
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative__member_createUserAgent",
|
|
139
|
-
"memberFieldName": "createUserAgent"
|
|
140
|
-
},
|
|
141
163
|
{
|
|
142
164
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative__member_test",
|
|
143
165
|
"memberFieldName": "test"
|
|
@@ -169,6 +191,12 @@
|
|
|
169
191
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_bus"
|
|
170
192
|
}
|
|
171
193
|
},
|
|
194
|
+
{
|
|
195
|
+
"keyRaw": "busFailMessage",
|
|
196
|
+
"value": {
|
|
197
|
+
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_busFailMessage"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
172
200
|
{
|
|
173
201
|
"keyRaw": "beforeActors",
|
|
174
202
|
"value": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-native/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-native/^4.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/actor-http-native",
|
|
6
6
|
"@type": "Module",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
|
|
4
4
|
{
|
|
5
5
|
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
-
"cahn": "npmd:@comunica/actor-http-native/^
|
|
6
|
+
"cahn": "npmd:@comunica/actor-http-native/^4.0.0/",
|
|
7
7
|
"ActorHttpNative": {
|
|
8
8
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative",
|
|
9
9
|
"@prefix": true,
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"args_bus": {
|
|
18
18
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_bus"
|
|
19
19
|
},
|
|
20
|
+
"args_busFailMessage": {
|
|
21
|
+
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_busFailMessage"
|
|
22
|
+
},
|
|
20
23
|
"args_beforeActors": {
|
|
21
24
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_beforeActors",
|
|
22
25
|
"@container": "@list"
|
|
@@ -30,6 +33,9 @@
|
|
|
30
33
|
"bus": {
|
|
31
34
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_bus"
|
|
32
35
|
},
|
|
36
|
+
"busFailMessage": {
|
|
37
|
+
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_busFailMessage"
|
|
38
|
+
},
|
|
33
39
|
"beforeActors": {
|
|
34
40
|
"@id": "cahn:components/ActorHttpNative.jsonld#ActorHttpNative_args_beforeActors",
|
|
35
41
|
"@container": "@list"
|
package/lib/ActorHttpNative.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { IActionHttp, IActorHttpOutput, IActorHttpArgs } from '@comunica/bus-http';
|
|
2
2
|
import { ActorHttp } from '@comunica/bus-http';
|
|
3
|
+
import type { TestResult } from '@comunica/core';
|
|
3
4
|
import type { IMediatorTypeTime } from '@comunica/mediatortype-time';
|
|
4
|
-
import 'cross-fetch/polyfill';
|
|
5
5
|
/**
|
|
6
6
|
* A comunica Follow Redirects Http Actor.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ActorHttpNative extends ActorHttp {
|
|
9
|
-
private readonly userAgent;
|
|
9
|
+
private static readonly userAgent;
|
|
10
10
|
private readonly requester;
|
|
11
11
|
constructor(args: IActorHttpNativeArgs);
|
|
12
|
-
|
|
13
|
-
test(action: IActionHttp): Promise<IMediatorTypeTime>;
|
|
12
|
+
test(_action: IActionHttp): Promise<TestResult<IMediatorTypeTime>>;
|
|
14
13
|
run(action: IActionHttp): Promise<IActorHttpOutput>;
|
|
15
14
|
}
|
|
16
15
|
export interface IActorHttpNativeArgs extends IActorHttpArgs {
|
package/lib/ActorHttpNative.js
CHANGED
|
@@ -3,25 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ActorHttpNative = void 0;
|
|
4
4
|
const bus_http_1 = require("@comunica/bus-http");
|
|
5
5
|
const context_entries_1 = require("@comunica/context-entries");
|
|
6
|
-
require("
|
|
6
|
+
const core_1 = require("@comunica/core");
|
|
7
|
+
// eslint-disable-next-line import/extensions
|
|
8
|
+
const package_json_1 = require("../package.json");
|
|
7
9
|
const Requester_1 = require("./Requester");
|
|
8
|
-
const process = require('process/');
|
|
9
10
|
/**
|
|
10
11
|
* A comunica Follow Redirects Http Actor.
|
|
11
12
|
*/
|
|
12
13
|
class ActorHttpNative extends bus_http_1.ActorHttp {
|
|
13
14
|
constructor(args) {
|
|
14
15
|
super(args);
|
|
15
|
-
this.userAgent = ActorHttpNative.createUserAgent();
|
|
16
16
|
this.requester = new Requester_1.default(args.agentOptions);
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
`Node.js ${process.version}; ${process.platform}` :
|
|
21
|
-
`Browser-${globalThis.navigator.userAgent}`})`;
|
|
22
|
-
}
|
|
23
|
-
async test(action) {
|
|
24
|
-
return { time: Number.POSITIVE_INFINITY };
|
|
18
|
+
async test(_action) {
|
|
19
|
+
return (0, core_1.passTest)({ time: Number.POSITIVE_INFINITY });
|
|
25
20
|
}
|
|
26
21
|
async run(action) {
|
|
27
22
|
const options = {};
|
|
@@ -49,7 +44,7 @@ class ActorHttpNative extends bus_http_1.ActorHttp {
|
|
|
49
44
|
options.headers = new Headers();
|
|
50
45
|
}
|
|
51
46
|
if (!options.headers.has('user-agent')) {
|
|
52
|
-
options.headers.append('user-agent',
|
|
47
|
+
options.headers.append('user-agent', ActorHttpNative.userAgent);
|
|
53
48
|
}
|
|
54
49
|
options.method = options.method || 'GET';
|
|
55
50
|
if (action.context.get(context_entries_1.KeysHttp.includeCredentials)) {
|
|
@@ -111,4 +106,5 @@ class ActorHttpNative extends bus_http_1.ActorHttp {
|
|
|
111
106
|
}
|
|
112
107
|
}
|
|
113
108
|
exports.ActorHttpNative = ActorHttpNative;
|
|
109
|
+
ActorHttpNative.userAgent = bus_http_1.ActorHttp.createUserAgent('ActorHttpNative', package_json_1.version);
|
|
114
110
|
//# sourceMappingURL=ActorHttpNative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorHttpNative.js","sourceRoot":"","sources":["ActorHttpNative.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAC/C,+DAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"ActorHttpNative.js","sourceRoot":"","sources":["ActorHttpNative.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAC/C,+DAAqD;AAErD,yCAA0C;AAG1C,6CAA6C;AAC7C,kDAA0D;AAE1D,2CAAoC;AAEpC;;GAEG;AACH,MAAa,eAAgB,SAAQ,oBAAS;IAK5C,YAAmB,IAA0B;QAC3C,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAoB;QACpC,OAAO,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACtD,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAmB;QAClC,MAAM,OAAO,GAAQ,EAAE,CAAC;QACxB,4CAA4C;QAC5C,gFAAgF;QAChF,IAAU,MAAM,CAAC,KAAM,CAAC,GAAG,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,GAAa,MAAM,CAAC,KAAM,CAAC,GAAG,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,OAAO,C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zB,CAAC;iCAAM,CAAC;gCACN,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;4BAC7E,CAAC;wBACH,CAAC;wBAED,+CAA+C;wBAC/C,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;wBAErC,MAAM,MAAM,GAAsB;4BAChC,IAAI,EAAE,YAAY;4BAClB,OAAO;4BACP,EAAE,EAAE,YAAY,CAAC,UAAU,GAAG,GAAG;4BACjC,UAAU,EAAE,OAAO,CAAC,GAAG,KAAK,YAAY,CAAC,WAAW;4BACpD,MAAM,EAAE,YAAY,CAAC,UAAU;4BAC/B,sGAAsG;4BACtG,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW;yBAClG,CAAC;wBACF,OAAO,CAAC,MAAM,CAAC,CAAC;oBAClB,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AA1GH,0CA2GC;AA1GyB,yBAAS,GAAG,oBAAS,CAAC,eAAe,CAAC,iBAAiB,EAAE,sBAAY,CAAC,CAAC","sourcesContent":["import type { IActionHttp, IActorHttpOutput, IActorHttpArgs } from '@comunica/bus-http';\nimport { ActorHttp } from '@comunica/bus-http';\nimport { KeysHttp } from '@comunica/context-entries';\nimport type { TestResult } from '@comunica/core';\nimport { passTest } from '@comunica/core';\nimport type { IMediatorTypeTime } from '@comunica/mediatortype-time';\n\n// eslint-disable-next-line import/extensions\nimport { version as actorVersion } from '../package.json';\n\nimport Requester from './Requester';\n\n/**\n * A comunica Follow Redirects Http Actor.\n */\nexport class ActorHttpNative extends ActorHttp {\n private static readonly userAgent = ActorHttp.createUserAgent('ActorHttpNative', actorVersion);\n\n private readonly requester: Requester;\n\n public constructor(args: IActorHttpNativeArgs) {\n super(args);\n this.requester = new Requester(args.agentOptions);\n }\n\n public async test(_action: IActionHttp): Promise<TestResult<IMediatorTypeTime>> {\n return passTest({ time: Number.POSITIVE_INFINITY });\n }\n\n public async run(action: IActionHttp): Promise<IActorHttpOutput> {\n const options: any = {};\n // Input can be a Request object or a string\n // if it is a Request object it can contain the same settings as the init object\n if ((<any>action.input).url) {\n options.url = (<Request>action.input).url;\n Object.assign(options, action.input);\n } else {\n options.url = action.input;\n }\n\n if (action.init) {\n Object.assign(options, action.init);\n options.headers = new Headers(action.init.headers);\n options.body = action.init.body;\n } else {\n options.headers = (<Request>action.input).headers;\n if ((<Request>action.input).body) {\n throw new Error(`ActorHttpNative does not support passing body via input, use init instead.`);\n }\n }\n\n if (!options.headers) {\n options.headers = new Headers();\n }\n if (!options.headers.has('user-agent')) {\n options.headers.append('user-agent', ActorHttpNative.userAgent);\n }\n\n options.method = options.method || 'GET';\n if (action.context.get(KeysHttp.includeCredentials)) {\n options.withCredentials = true;\n }\n\n if (action.context.get(KeysHttp.auth)) {\n options.auth = action.context.get(KeysHttp.auth);\n }\n\n this.logInfo(action.context, `Requesting ${options.url}`, () => ({\n headers: ActorHttp.headersToHash(options.headers),\n method: options.method,\n }));\n\n // Not all options are supported\n\n return new Promise<IActorHttpOutput>((resolve, reject) => {\n const req = this.requester.createRequest(options);\n req.on('error', reject);\n req.on('response', (httpResponse) => {\n httpResponse.on('error', (error: Error) => {\n httpResponse = null;\n reject(error);\n });\n // Avoid memory leak on HEAD requests\n if (options.method === 'HEAD') {\n httpResponse.destroy();\n }\n // Using setImmediate so error can be caught should it be thrown\n setTimeout(() => {\n if (httpResponse) {\n // Expose fetch cancel promise\n httpResponse.cancel = () => {\n httpResponse.destroy();\n return Promise.resolve();\n };\n\n // Support abort controller\n if (action.init?.signal) {\n if (action.init.signal.aborted) {\n httpResponse.destroy();\n } else {\n action.init.signal.addEventListener('abort', () => httpResponse.destroy());\n }\n }\n\n // Missing several of the required fetch fields\n const headers = httpResponse.headers;\n\n const result = <IActorHttpOutput> {\n body: httpResponse,\n headers,\n ok: httpResponse.statusCode < 300,\n redirected: options.url !== httpResponse.responseUrl,\n status: httpResponse.statusCode,\n // When the content came from another resource because of conneg, let Content-Location deliver the url\n url: headers.has('content-location') ? headers.get('content-location') : httpResponse.responseUrl,\n };\n resolve(result);\n }\n });\n });\n });\n }\n}\n\nexport interface IActorHttpNativeArgs extends IActorHttpArgs {\n /**\n * The agent options for the HTTP agent\n * @range {json}\n * @default {{ \"keepAlive\": true, \"maxSockets\": 5 }}\n */\n agentOptions?: Record<string, any>;\n}\n"]}
|
package/lib/Requester-browser.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable unicorn/filename-case */
|
|
3
|
-
/* eslint-enable unicorn/filename-case */
|
|
4
2
|
/* ! @license MIT ©2013-2016 Ruben Verborgh, Ghent University - imec */
|
|
5
3
|
/* Single-function HTTP(S) request module for browsers */
|
|
6
4
|
/* Translated from https://github.com/LinkedDataFragments/Client.js/blob/master/lib/browser/Request.js */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Requester-browser.js","sourceRoot":"","sources":["Requester-browser.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"Requester-browser.js","sourceRoot":"","sources":["Requester-browser.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,yDAAyD;AACzD,yGAAyG;;AAEzG,6CAA2C;AAE3C,6CAAuC;AACvC,uDAAyC;AAEzC,mGAAmG;AACnG,MAAM,sBAAsB,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAE9F,MAAqB,SAAS;IAI5B;QACE,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;IAChC,CAAC;IAED,kDAAkD;IAC3C,aAAa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C,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,0CAA0C;IACnC,mCAAmC,CAAC,OAA4B;QACrE,MAAM,eAAe,GAAY,IAAI,OAAO,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,eAAe,CAAC,MAAM,CAAC,GAAG,EAAW,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,sCAAsC;IAC9B,WAAW,CAAC,GAAY;QAC9B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,CAAC;CACF;AAlHD,4BAkHC","sourcesContent":["/* ! @license MIT ©2013-2016 Ruben Verborgh, Ghent University - imec */\n/* Single-function HTTP(S) request module for browsers */\n/* Translated from https://github.com/LinkedDataFragments/Client.js/blob/master/lib/browser/Request.js */\n\nimport { EventEmitter } from 'node:events';\nimport type { IncomingHttpHeaders, IncomingMessage } from 'node:http';\nimport { Readable } from 'node:stream';\nimport { parse } from 'http-link-header';\n\n// Headers we cannot send (see https://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method)\nconst UNSAFE_REQUEST_HEADERS = { 'accept-encoding': true, 'user-agent': true, referer: true };\n\nexport default class Requester {\n // Resources that were already time-negotiated\n private negotiatedResources: Record<string, boolean>;\n\n public constructor() {\n this.negotiatedResources = {};\n }\n\n // Creates an HTTP request with the given settings\n public createRequest(settings: any): EventEmitter {\n // PERFORMANCE HACK:\n // Reduce OPTIONS preflight requests by removing the Accept-Datetime header\n // on requests for resources that are presumed to have been time-negotiated\n if (this.negotiatedResources[this.removeQuery(settings.url)]) {\n (<Headers> settings.headers).delete('accept-datetime');\n }\n\n // Create the actual XMLHttpRequest\n const request = new XMLHttpRequest();\n const reqHeaders: Headers = settings.headers;\n request.open(settings.method, settings.url, true);\n request.timeout = settings.timeout;\n request.withCredentials = settings.withCredentials;\n\n // eslint-disable-next-line unicorn/no-array-for-each\n reqHeaders.forEach((value, key) => {\n if (!(key in UNSAFE_REQUEST_HEADERS) && value) {\n request.setRequestHeader(key, value);\n }\n });\n\n // Create a proxy for the XMLHttpRequest\n const requestProxy = new EventEmitter();\n (<any> requestProxy).abort = () => {\n request.abort();\n };\n\n // Handle the arrival of a response\n request.onload = () => {\n // Convert the response into an iterator\n const response: IncomingMessage = <IncomingMessage> new Readable();\n response.push(request.responseText || '');\n response.push(null);\n response.statusCode = request.status;\n (<any> response).responseUrl = request.responseURL;\n\n // Parse the response headers\n const resHeaders: Headers = this.convertRequestHeadersToFetchHeaders(response.headers);\n response.headers = <any> resHeaders;\n const rawHeaders = request.getAllResponseHeaders() || '';\n const headerMatcher = /^([^\\n\\r:]+):[\\t ]*([^\\n\\r]*)$/gmu;\n let match = headerMatcher.exec(rawHeaders);\n while (match) {\n resHeaders.set(match[1].toLowerCase(), match[2]);\n match = headerMatcher.exec(rawHeaders);\n }\n\n // Emit the response\n requestProxy.emit('response', response);\n\n // If the resource was time-negotiated, store its queryless URI\n // to enable the PERFORMANCE HACK explained above\n if (reqHeaders.has('accept-datetime') && resHeaders.has('memento-datetime')) {\n const resource = this.removeQuery(resHeaders.get('content-location') ?? settings.url);\n if (!this.negotiatedResources[resource]) {\n // Ensure the resource is not a timegate\n const header = resHeaders.get('link');\n const tg = header && parse(header)?.get('rel', 'timegate');\n const timegate = this.removeQuery(tg && tg.length > 0 ? tg[0].uri : undefined);\n if (resource !== timegate) {\n this.negotiatedResources[resource] = true;\n }\n }\n }\n };\n // Report errors and timeouts\n request.onerror = () => {\n requestProxy.emit('error', new Error(`Error requesting ${settings.url}`));\n };\n request.ontimeout = () => {\n requestProxy.emit('error', new Error(`Timeout requesting ${settings.url}`));\n };\n\n // Execute the request\n if (settings.body) {\n if (settings.body instanceof URLSearchParams) {\n request.send(settings.body.toString());\n } else if (typeof settings.body === 'string') {\n request.send(settings.body);\n } else {\n settings.body.blob()\n .then((blob: any) => request.send(blob))\n .catch((error: Error) => requestProxy.emit('error', error));\n }\n } else {\n request.send();\n }\n\n return requestProxy;\n }\n\n // Wrap headers into an header object type\n public convertRequestHeadersToFetchHeaders(headers: IncomingHttpHeaders): Headers {\n const responseHeaders: Headers = new Headers();\n for (const key in headers) {\n responseHeaders.append(key, <string> headers[key]);\n }\n return responseHeaders;\n }\n\n // Removes the query string from a URL\n private removeQuery(url?: string): string {\n return url ? url.replace(/\\?.*$/u, '') : '';\n }\n}\n"]}
|
package/lib/Requester.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { EventEmitter } from 'node:events';
|
|
4
4
|
import type { AgentOptions, IncomingHttpHeaders } from 'node:http';
|
|
5
|
-
import 'cross-fetch/polyfill';
|
|
6
5
|
export default class Requester {
|
|
7
6
|
private readonly agents;
|
|
8
7
|
constructor(agentOptions?: AgentOptions);
|
package/lib/Requester.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_events_1 = require("node:events");
|
|
7
7
|
const url = require("node:url");
|
|
8
8
|
const zlib = require("node:zlib");
|
|
9
|
-
require("cross-fetch/polyfill");
|
|
10
9
|
const bus_http_1 = require("@comunica/bus-http");
|
|
11
10
|
const { http } = require('follow-redirects');
|
|
12
11
|
const { https } = require('follow-redirects');
|
package/lib/Requester.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Requester.js","sourceRoot":"","sources":["Requester.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,4CAA4C;AAC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,OAAO,CAAC,CAAC;QACpF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAxFD,4BAwFC","sourcesContent":["/* ! @license MIT ©2016 Ruben Verborgh, Ghent University - imec */\n/* Single-function HTTP(S) request module */\n/* Translated from https://github.com/LinkedDataFragments/Client.js/blob/master/lib/util/Request.js */\n\nimport { EventEmitter } from 'node:events';\nimport type { AgentOptions, ClientRequest, IncomingMessage, IncomingHttpHeaders } from 'node:http';\nimport * as url from 'node:url';\nimport * as zlib from 'node:zlib';\nimport { ActorHttp } from '@comunica/bus-http';\n\nconst { http } = require('follow-redirects');\nconst { https } = require('follow-redirects');\n\n// Decode encoded streams with these decoders\nconst DECODERS = { gzip: zlib.createGunzip, deflate: zlib.createInflate };\n\nexport default class Requester {\n private readonly agents: any;\n\n public constructor(agentOptions?: AgentOptions) {\n this.agents = {\n http: new http.Agent(agentOptions ?? {}),\n https: new https.Agent(agentOptions ?? {}),\n };\n }\n\n // Creates an HTTP request with the given settings\n public createRequest(settings: any): EventEmitter {\n // Parse the request URL\n if (settings.url) {\n // eslint-disable-next-line node/no-deprecated-api\n settings = { ...url.parse(settings.url), ...settings };\n }\n\n // Emit the response through a proxy\n const requestProxy = new EventEmitter();\n const requester = settings.protocol === 'http:' ? http : https;\n settings.agents = this.agents;\n\n // Unpacking headers object into a plain object\n const headersObject: any = {};\n if (settings.headers) {\n // eslint-disable-next-line unicorn/no-array-for-each\n (<Headers> settings.headers).forEach((value, key) => {\n headersObject[key] = value;\n });\n }\n settings.headers = headersObject;\n const request: ClientRequest = requester.request(settings, (response: IncomingMessage) => {\n response = this.decode(response);\n settings.headers = response.headers;\n response.setEncoding('utf8');\n // This was removed compared to the original LDF client implementation\n // response.pause(); // exit flow mode\n requestProxy.emit('response', response);\n });\n request.on('error', error => requestProxy.emit('error', error));\n if (settings.body) {\n if (settings.body instanceof URLSearchParams) {\n request.write(settings.body.toString());\n request.end();\n } else if (typeof settings.body === 'string') {\n request.write(settings.body);\n request.end();\n } else {\n ActorHttp.toNodeReadable(settings.body).pipe(request);\n }\n } else {\n request.end();\n }\n return requestProxy;\n }\n\n // Wrap headers into an header object type\n public convertRequestHeadersToFetchHeaders(headers: IncomingHttpHeaders): Headers {\n const responseHeaders: Headers = new Headers();\n for (const key in headers) {\n responseHeaders.append(key, <string> headers[key]);\n }\n return responseHeaders;\n }\n\n // Returns a decompressed stream from the HTTP response\n private decode(response: IncomingMessage): IncomingMessage {\n const encoding = response.headers['content-encoding'];\n if (encoding) {\n if (encoding in DECODERS) {\n // Decode the stream\n const decoded = (<any> DECODERS)[encoding]();\n response.pipe(decoded);\n // Copy response properties\n decoded.statusCode = response.statusCode;\n decoded.headers = this.convertRequestHeadersToFetchHeaders(response.headers);\n return decoded;\n }\n // Error when no suitable decoder found\n setTimeout(() => {\n response.emit('error', new Error(`Unsupported encoding: ${encoding}`));\n });\n }\n\n response.headers = <any> this.convertRequestHeadersToFetchHeaders(response.headers);\n return response;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-http-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A native http actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"funding": {
|
|
8
|
+
"type": "opencollective",
|
|
9
|
+
"url": "https://opencollective.com/comunica-association"
|
|
10
|
+
},
|
|
7
11
|
"homepage": "https://comunica.dev/",
|
|
8
12
|
"repository": {
|
|
9
13
|
"type": "git",
|
|
@@ -37,17 +41,16 @@
|
|
|
37
41
|
"build:components": "componentsjs-generator"
|
|
38
42
|
},
|
|
39
43
|
"dependencies": {
|
|
40
|
-
"@comunica/bus-http": "^
|
|
41
|
-
"@comunica/context-entries": "^
|
|
42
|
-
"@comunica/
|
|
44
|
+
"@comunica/bus-http": "^4.0.1",
|
|
45
|
+
"@comunica/context-entries": "^4.0.1",
|
|
46
|
+
"@comunica/core": "^4.0.1",
|
|
47
|
+
"@comunica/mediatortype-time": "^4.0.1",
|
|
43
48
|
"@types/http-link-header": "^1.0.7",
|
|
44
|
-
"cross-fetch": "^4.0.0",
|
|
45
49
|
"follow-redirects": "^1.15.2",
|
|
46
|
-
"http-link-header": "^1.1.3"
|
|
47
|
-
"process": "^0.11.10"
|
|
50
|
+
"http-link-header": "^1.1.3"
|
|
48
51
|
},
|
|
49
52
|
"browser": {
|
|
50
53
|
"./lib/Requester.js": "./lib/Requester-browser.js"
|
|
51
54
|
},
|
|
52
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "67831ba79e45ea1ced41fe3f83c5d6e8802dbeaa"
|
|
53
56
|
}
|