urllib 2.38.1 → 3.0.0

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.
Files changed (55) hide show
  1. package/README.md +75 -264
  2. package/package.json +62 -59
  3. package/src/HttpAgent.ts +72 -0
  4. package/src/HttpClient.ts +514 -0
  5. package/src/Request.ts +118 -0
  6. package/src/Response.ts +41 -0
  7. package/src/cjs/HttpAgent.d.ts +16 -0
  8. package/src/cjs/HttpAgent.js +62 -0
  9. package/src/cjs/HttpAgent.js.map +1 -0
  10. package/src/cjs/HttpClient.d.ts +39 -0
  11. package/src/cjs/HttpClient.js +466 -0
  12. package/src/cjs/HttpClient.js.map +1 -0
  13. package/src/cjs/Request.d.ts +114 -0
  14. package/src/cjs/Request.js +3 -0
  15. package/src/cjs/Request.js.map +1 -0
  16. package/src/cjs/Response.d.ts +36 -0
  17. package/src/cjs/Response.js +3 -0
  18. package/src/cjs/Response.js.map +1 -0
  19. package/src/cjs/index.d.ts +7 -0
  20. package/src/cjs/index.js +18 -0
  21. package/src/cjs/index.js.map +1 -0
  22. package/src/cjs/package.json +3 -0
  23. package/src/cjs/utils.d.ts +3 -0
  24. package/src/cjs/utils.js +56 -0
  25. package/src/cjs/utils.js.map +1 -0
  26. package/src/esm/HttpAgent.d.ts +16 -0
  27. package/src/esm/HttpAgent.js +58 -0
  28. package/src/esm/HttpAgent.js.map +1 -0
  29. package/src/esm/HttpClient.d.ts +39 -0
  30. package/src/esm/HttpClient.js +462 -0
  31. package/src/esm/HttpClient.js.map +1 -0
  32. package/src/esm/Request.d.ts +114 -0
  33. package/src/esm/Request.js +2 -0
  34. package/src/esm/Request.js.map +1 -0
  35. package/src/esm/Response.d.ts +36 -0
  36. package/src/esm/Response.js +2 -0
  37. package/src/esm/Response.js.map +1 -0
  38. package/src/esm/index.d.ts +7 -0
  39. package/src/esm/index.js +13 -0
  40. package/src/esm/index.js.map +1 -0
  41. package/src/esm/package.json +3 -0
  42. package/src/esm/utils.d.ts +3 -0
  43. package/src/esm/utils.js +51 -0
  44. package/src/esm/utils.js.map +1 -0
  45. package/src/index.ts +16 -0
  46. package/src/utils.ts +53 -0
  47. package/History.md +0 -804
  48. package/lib/detect_proxy_agent.js +0 -31
  49. package/lib/get_proxy_from_uri.js +0 -81
  50. package/lib/httpclient.js +0 -61
  51. package/lib/httpclient2.js +0 -83
  52. package/lib/index.d.ts +0 -279
  53. package/lib/index.js +0 -21
  54. package/lib/index.test-d.ts +0 -19
  55. package/lib/urllib.js +0 -1317
@@ -0,0 +1,462 @@
1
+ var _a, _b, _c;
2
+ var _BlobFromStream_stream, _BlobFromStream_type, _HttpClient_instances, _HttpClient_defaultArgs, _HttpClient_dispatcher, _HttpClient_requestInternal;
3
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
4
+ import { EventEmitter } from 'events';
5
+ import { debuglog } from 'util';
6
+ import { createGunzip, createBrotliDecompress, gunzipSync, brotliDecompressSync, } from 'zlib';
7
+ import { Blob } from 'buffer';
8
+ import { Readable, pipeline } from 'stream';
9
+ import stream from 'stream';
10
+ import { basename } from 'path';
11
+ import { createReadStream } from 'fs';
12
+ import { performance } from 'perf_hooks';
13
+ import { FormData as FormDataNative, request as undiciRequest, } from 'undici';
14
+ import { FormData as FormDataNode } from 'formdata-node';
15
+ import { FormDataEncoder } from 'form-data-encoder';
16
+ import createUserAgent from 'default-user-agent';
17
+ import mime from 'mime-types';
18
+ import pump from 'pump';
19
+ import { HttpAgent } from './HttpAgent.js';
20
+ import { parseJSON, sleep } from './utils.js';
21
+ const FormData = FormDataNative !== null && FormDataNative !== void 0 ? FormDataNative : FormDataNode;
22
+ // impl isReadable on Node.js 14
23
+ const isReadable = (_a = stream.isReadable) !== null && _a !== void 0 ? _a : function isReadable(stream) {
24
+ return stream && typeof stream.read === 'function';
25
+ };
26
+ // impl promise pipeline on Node.js 14
27
+ const pipelinePromise = (_c = (_b = stream.promises) === null || _b === void 0 ? void 0 : _b.pipeline) !== null && _c !== void 0 ? _c : function pipeline(...args) {
28
+ return new Promise((resolve, reject) => {
29
+ pump(...args, (err) => {
30
+ if (err)
31
+ return reject(err);
32
+ resolve();
33
+ });
34
+ });
35
+ };
36
+ function noop() {
37
+ // noop
38
+ }
39
+ const MAX_REQURE_ID_VALUE = Math.pow(2, 31) - 10;
40
+ let globalRequestId = 0;
41
+ const debug = debuglog('urllib');
42
+ // https://github.com/octet-stream/form-data
43
+ class BlobFromStream {
44
+ constructor(stream, type) {
45
+ _BlobFromStream_stream.set(this, void 0);
46
+ _BlobFromStream_type.set(this, void 0);
47
+ __classPrivateFieldSet(this, _BlobFromStream_stream, stream, "f");
48
+ __classPrivateFieldSet(this, _BlobFromStream_type, type, "f");
49
+ }
50
+ stream() {
51
+ return __classPrivateFieldGet(this, _BlobFromStream_stream, "f");
52
+ }
53
+ get type() {
54
+ return __classPrivateFieldGet(this, _BlobFromStream_type, "f");
55
+ }
56
+ get [(_BlobFromStream_stream = new WeakMap(), _BlobFromStream_type = new WeakMap(), Symbol.toStringTag)]() {
57
+ return 'Blob';
58
+ }
59
+ }
60
+ class HttpClientRequestTimeoutError extends Error {
61
+ constructor(timeout, options) {
62
+ const message = `Request timeout for ${timeout} ms`;
63
+ super(message, options);
64
+ this.name = this.constructor.name;
65
+ Error.captureStackTrace(this, this.constructor);
66
+ }
67
+ }
68
+ const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.0.0');
69
+ function getFileName(stream) {
70
+ const filePath = stream.path;
71
+ if (filePath) {
72
+ return basename(filePath);
73
+ }
74
+ return '';
75
+ }
76
+ function defaultIsRetry(response) {
77
+ return response.status >= 500;
78
+ }
79
+ function performanceTime(startTime) {
80
+ return Math.floor((performance.now() - startTime) * 1000) / 1000;
81
+ }
82
+ export class HttpClient extends EventEmitter {
83
+ constructor(clientOptions) {
84
+ super();
85
+ _HttpClient_instances.add(this);
86
+ _HttpClient_defaultArgs.set(this, void 0);
87
+ _HttpClient_dispatcher.set(this, void 0);
88
+ __classPrivateFieldSet(this, _HttpClient_defaultArgs, clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.defaultArgs, "f");
89
+ if ((clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.lookup) || (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.checkAddress) || (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.connect)) {
90
+ __classPrivateFieldSet(this, _HttpClient_dispatcher, new HttpAgent({
91
+ lookup: clientOptions.lookup,
92
+ checkAddress: clientOptions.checkAddress,
93
+ connect: clientOptions.connect,
94
+ }), "f");
95
+ }
96
+ }
97
+ async request(url, options) {
98
+ return await __classPrivateFieldGet(this, _HttpClient_instances, "m", _HttpClient_requestInternal).call(this, url, options);
99
+ }
100
+ }
101
+ _HttpClient_defaultArgs = new WeakMap(), _HttpClient_dispatcher = new WeakMap(), _HttpClient_instances = new WeakSet(), _HttpClient_requestInternal = async function _HttpClient_requestInternal(url, options, requestContext) {
102
+ var _a, _b, _c, _d, _e, _f;
103
+ if (globalRequestId >= MAX_REQURE_ID_VALUE) {
104
+ globalRequestId = 0;
105
+ }
106
+ const requestId = ++globalRequestId;
107
+ const requestUrl = typeof url === 'string' ? new URL(url) : url;
108
+ const args = {
109
+ retry: 0,
110
+ ...__classPrivateFieldGet(this, _HttpClient_defaultArgs, "f"),
111
+ ...options,
112
+ };
113
+ requestContext = {
114
+ retries: 0,
115
+ ...requestContext,
116
+ };
117
+ const requestStartTime = performance.now();
118
+ const reqMeta = {
119
+ requestId,
120
+ url: requestUrl.href,
121
+ args,
122
+ ctx: args.ctx,
123
+ };
124
+ // keep urllib createCallbackResponse style
125
+ const resHeaders = {};
126
+ const res = {
127
+ status: -1,
128
+ statusCode: -1,
129
+ headers: resHeaders,
130
+ size: 0,
131
+ aborted: false,
132
+ rt: 0,
133
+ keepAliveSocket: true,
134
+ requestUrls: [],
135
+ timing: {
136
+ waiting: 0,
137
+ contentDownload: 0,
138
+ },
139
+ };
140
+ let headersTimeout = 5000;
141
+ let bodyTimeout = 5000;
142
+ if (args.timeout) {
143
+ if (Array.isArray(args.timeout)) {
144
+ headersTimeout = (_a = args.timeout[0]) !== null && _a !== void 0 ? _a : headersTimeout;
145
+ bodyTimeout = (_b = args.timeout[1]) !== null && _b !== void 0 ? _b : bodyTimeout;
146
+ }
147
+ else {
148
+ headersTimeout = bodyTimeout = args.timeout;
149
+ }
150
+ }
151
+ const method = ((_c = args.method) !== null && _c !== void 0 ? _c : 'GET').toUpperCase();
152
+ const headers = {};
153
+ if (args.headers) {
154
+ // convert headers to lower-case
155
+ for (const name in args.headers) {
156
+ headers[name.toLowerCase()] = args.headers[name];
157
+ }
158
+ }
159
+ // hidden user-agent
160
+ const hiddenUserAgent = 'user-agent' in headers && !headers['user-agent'];
161
+ if (hiddenUserAgent) {
162
+ delete headers['user-agent'];
163
+ }
164
+ else if (!headers['user-agent']) {
165
+ // need to set user-agent
166
+ headers['user-agent'] = HEADER_USER_AGENT;
167
+ }
168
+ // Alias to dataType = 'stream'
169
+ if (args.streaming || args.customResponse) {
170
+ args.dataType = 'stream';
171
+ }
172
+ if (args.dataType === 'json' && !headers.accept) {
173
+ headers.accept = 'application/json';
174
+ }
175
+ // gzip alias to compressed
176
+ if (args.gzip && args.compressed !== false) {
177
+ args.compressed = true;
178
+ }
179
+ if (args.compressed && !headers['accept-encoding']) {
180
+ headers['accept-encoding'] = 'gzip, br';
181
+ }
182
+ if (requestContext.retries > 0) {
183
+ headers['x-urllib-retry'] = `${requestContext.retries}/${args.retry}`;
184
+ }
185
+ if (args.auth && !headers.authorization) {
186
+ headers.authorization = `Basic ${Buffer.from(args.auth).toString('base64')}`;
187
+ }
188
+ let opaque = args.opaque;
189
+ try {
190
+ const requestOptions = {
191
+ method,
192
+ keepalive: true,
193
+ maxRedirections: (_d = args.maxRedirects) !== null && _d !== void 0 ? _d : 10,
194
+ headersTimeout,
195
+ bodyTimeout,
196
+ opaque,
197
+ dispatcher: __classPrivateFieldGet(this, _HttpClient_dispatcher, "f"),
198
+ };
199
+ if (args.followRedirect === false) {
200
+ requestOptions.maxRedirections = 0;
201
+ }
202
+ const isGETOrHEAD = requestOptions.method === 'GET' || requestOptions.method === 'HEAD';
203
+ // alias to args.content
204
+ if (args.stream && !args.content) {
205
+ args.content = args.stream;
206
+ }
207
+ if (args.files) {
208
+ if (isGETOrHEAD) {
209
+ requestOptions.method = 'POST';
210
+ }
211
+ const formData = new FormData();
212
+ const uploadFiles = [];
213
+ if (Array.isArray(args.files)) {
214
+ for (const [index, file] of args.files.entries()) {
215
+ const field = index === 0 ? 'file' : `file${index}`;
216
+ uploadFiles.push([field, file]);
217
+ }
218
+ }
219
+ else if (args.files instanceof Readable || isReadable(args.files)) {
220
+ uploadFiles.push(['file', args.files]);
221
+ }
222
+ else if (typeof args.files === 'string' || Buffer.isBuffer(args.files)) {
223
+ uploadFiles.push(['file', args.files]);
224
+ }
225
+ else if (typeof args.files === 'object') {
226
+ for (const field in args.files) {
227
+ uploadFiles.push([field, args.files[field]]);
228
+ }
229
+ }
230
+ // set normal fields first
231
+ if (args.data) {
232
+ for (const field in args.data) {
233
+ formData.append(field, args.data[field]);
234
+ }
235
+ }
236
+ for (const [index, [field, file]] of uploadFiles.entries()) {
237
+ if (typeof file === 'string') {
238
+ // FIXME: support non-ascii filename
239
+ // const fileName = encodeURIComponent(basename(file));
240
+ // formData.append(field, await fileFromPath(file, `utf-8''${fileName}`, { type: mime.lookup(fileName) || '' }));
241
+ const fileName = basename(file);
242
+ const fileReadable = createReadStream(file);
243
+ formData.append(field, new BlobFromStream(fileReadable, mime.lookup(fileName) || ''), fileName);
244
+ }
245
+ else if (Buffer.isBuffer(file)) {
246
+ formData.append(field, new Blob([file]), `bufferfile${index}`);
247
+ }
248
+ else if (file instanceof Readable || isReadable(file)) {
249
+ const fileName = getFileName(file) || `streamfile${index}`;
250
+ formData.append(field, new BlobFromStream(file, mime.lookup(fileName) || ''), fileName);
251
+ }
252
+ }
253
+ if (FormDataNative) {
254
+ requestOptions.body = formData;
255
+ }
256
+ else {
257
+ // Node.js 14 does not support spec-compliant FormData
258
+ // https://github.com/octet-stream/form-data#usage
259
+ const encoder = new FormDataEncoder(formData);
260
+ Object.assign(headers, encoder.headers);
261
+ // fix "Content-Length":"NaN"
262
+ delete headers['Content-Length'];
263
+ requestOptions.body = Readable.from(encoder);
264
+ }
265
+ }
266
+ else if (args.content) {
267
+ if (!isGETOrHEAD) {
268
+ // handle content
269
+ requestOptions.body = args.content;
270
+ if (args.contentType) {
271
+ headers['content-type'] = args.contentType;
272
+ }
273
+ if (typeof args.content === 'string' && !headers['content-type']) {
274
+ headers['content-type'] = 'text/plain;charset=UTF-8';
275
+ }
276
+ }
277
+ }
278
+ else if (args.data) {
279
+ const isStringOrBufferOrReadable = typeof args.data === 'string'
280
+ || Buffer.isBuffer(args.data)
281
+ || isReadable(args.data);
282
+ if (isGETOrHEAD) {
283
+ if (!isStringOrBufferOrReadable) {
284
+ for (const field in args.data) {
285
+ requestUrl.searchParams.append(field, args.data[field]);
286
+ }
287
+ }
288
+ }
289
+ else {
290
+ if (isStringOrBufferOrReadable) {
291
+ requestOptions.body = args.data;
292
+ }
293
+ else {
294
+ if (args.contentType === 'json'
295
+ || args.contentType === 'application/json'
296
+ || ((_e = headers['content-type']) === null || _e === void 0 ? void 0 : _e.startsWith('application/json'))) {
297
+ requestOptions.body = JSON.stringify(args.data);
298
+ if (!headers['content-type']) {
299
+ headers['content-type'] = 'application/json';
300
+ }
301
+ }
302
+ else {
303
+ headers['content-type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
304
+ requestOptions.body = new URLSearchParams(args.data).toString();
305
+ }
306
+ }
307
+ }
308
+ }
309
+ debug('Request#%d %s %s, headers: %j, headersTimeout: %s, bodyTimeout: %s', requestId, requestOptions.method, requestUrl.href, headers, headersTimeout, bodyTimeout);
310
+ requestOptions.headers = headers;
311
+ if (this.listenerCount('request') > 0) {
312
+ this.emit('request', reqMeta);
313
+ }
314
+ const response = await undiciRequest(requestUrl, requestOptions);
315
+ opaque = response.opaque;
316
+ if (args.timing) {
317
+ res.timing.waiting = performanceTime(requestStartTime);
318
+ }
319
+ const context = response.context;
320
+ let lastUrl = '';
321
+ if (context === null || context === void 0 ? void 0 : context.history) {
322
+ for (const urlObject of context === null || context === void 0 ? void 0 : context.history) {
323
+ res.requestUrls.push(urlObject.href);
324
+ lastUrl = urlObject.href;
325
+ }
326
+ }
327
+ else {
328
+ res.requestUrls.push(requestUrl.href);
329
+ lastUrl = requestUrl.href;
330
+ }
331
+ const contentEncoding = response.headers['content-encoding'];
332
+ const isCompressedContent = contentEncoding === 'gzip' || contentEncoding === 'br';
333
+ res.headers = response.headers;
334
+ res.status = res.statusCode = response.statusCode;
335
+ if (res.headers['content-length']) {
336
+ res.size = parseInt(res.headers['content-length']);
337
+ }
338
+ let data = null;
339
+ let responseBodyStream;
340
+ if (args.dataType === 'stream') {
341
+ // streaming mode will disable retry
342
+ args.retry = 0;
343
+ const meta = {
344
+ status: res.status,
345
+ statusCode: res.statusCode,
346
+ headers: res.headers,
347
+ };
348
+ if (isCompressedContent) {
349
+ // gzip or br
350
+ const decoder = contentEncoding === 'gzip' ? createGunzip() : createBrotliDecompress();
351
+ responseBodyStream = Object.assign(pipeline(response.body, decoder, noop), meta);
352
+ }
353
+ else {
354
+ responseBodyStream = Object.assign(response.body, meta);
355
+ }
356
+ }
357
+ else if (args.writeStream) {
358
+ // streaming mode will disable retry
359
+ args.retry = 0;
360
+ if (isCompressedContent) {
361
+ const decoder = contentEncoding === 'gzip' ? createGunzip() : createBrotliDecompress();
362
+ await pipelinePromise(response.body, decoder, args.writeStream);
363
+ }
364
+ else {
365
+ await pipelinePromise(response.body, args.writeStream);
366
+ }
367
+ }
368
+ else {
369
+ // buffer
370
+ data = Buffer.from(await response.body.arrayBuffer());
371
+ if (isCompressedContent) {
372
+ try {
373
+ data = contentEncoding === 'gzip' ? gunzipSync(data) : brotliDecompressSync(data);
374
+ }
375
+ catch (err) {
376
+ if (err.name === 'Error') {
377
+ err.name = 'UnzipError';
378
+ }
379
+ throw err;
380
+ }
381
+ }
382
+ if (args.dataType === 'text') {
383
+ data = data.toString();
384
+ }
385
+ else if (args.dataType === 'json') {
386
+ if (data.length === 0) {
387
+ data = null;
388
+ }
389
+ else {
390
+ data = parseJSON(data.toString(), args.fixJSONCtlChars);
391
+ }
392
+ }
393
+ }
394
+ res.rt = performanceTime(requestStartTime);
395
+ if (args.timing) {
396
+ res.timing.contentDownload = res.rt;
397
+ }
398
+ const clientResponse = {
399
+ opaque,
400
+ data,
401
+ status: res.status,
402
+ headers: res.headers,
403
+ url: lastUrl,
404
+ redirected: res.requestUrls.length > 1,
405
+ requestUrls: res.requestUrls,
406
+ res: responseBodyStream !== null && responseBodyStream !== void 0 ? responseBodyStream : res,
407
+ };
408
+ if (args.retry > 0 && requestContext.retries < args.retry) {
409
+ const isRetry = (_f = args.isRetry) !== null && _f !== void 0 ? _f : defaultIsRetry;
410
+ if (isRetry(clientResponse)) {
411
+ if (args.retryDelay) {
412
+ await sleep(args.retryDelay);
413
+ }
414
+ requestContext.retries++;
415
+ return await __classPrivateFieldGet(this, _HttpClient_instances, "m", _HttpClient_requestInternal).call(this, url, options, requestContext);
416
+ }
417
+ }
418
+ if (this.listenerCount('response') > 0) {
419
+ this.emit('response', {
420
+ requestId,
421
+ error: null,
422
+ ctx: args.ctx,
423
+ req: reqMeta,
424
+ res,
425
+ });
426
+ }
427
+ return clientResponse;
428
+ }
429
+ catch (e) {
430
+ debug('Request#%d throw error: %s', requestId, e);
431
+ let err = e;
432
+ if (err.name === 'HeadersTimeoutError') {
433
+ err = new HttpClientRequestTimeoutError(headersTimeout, { cause: e });
434
+ }
435
+ else if (err.name === 'BodyTimeoutError') {
436
+ err = new HttpClientRequestTimeoutError(bodyTimeout, { cause: e });
437
+ }
438
+ err.opaque = opaque;
439
+ err.status = res.status;
440
+ err.headers = res.headers;
441
+ err.res = res;
442
+ // make sure requestUrls not empty
443
+ if (res.requestUrls.length === 0) {
444
+ res.requestUrls.push(requestUrl.href);
445
+ }
446
+ res.rt = performanceTime(requestStartTime);
447
+ if (args.timing) {
448
+ res.timing.contentDownload = res.rt;
449
+ }
450
+ if (this.listenerCount('response') > 0) {
451
+ this.emit('response', {
452
+ requestId,
453
+ error: err,
454
+ ctx: args.ctx,
455
+ req: reqMeta,
456
+ res,
457
+ });
458
+ }
459
+ throw err;
460
+ }
461
+ };
462
+ //# sourceMappingURL=HttpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["../HttpClient.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,UAAU,EACV,oBAAoB,GACrB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,OAAO,IAAI,aAAa,GAEzB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAC;AAG9D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M,KAAK,CAAC,EAAE;YAChC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACvC;QACD,GAAG,CAAC,EAAE,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAC3C,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,GAAG,CAAC,MAAM,CAAC,eAAe,GAAG,GAAG,CAAC,EAAE,CAAC;SACrC;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACpB,SAAS;gBACT,KAAK,EAAE,GAAG;gBACV,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,GAAG,EAAE,OAAO;gBACZ,GAAG;aACJ,CAAC,CAAC;SACJ;QACD,MAAM,GAAG,CAAC;KACX;AACH,CAAC"}
@@ -0,0 +1,114 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ import { Readable, Writable } from 'stream';
6
+ import { IncomingHttpHeaders } from 'http';
7
+ import type { HttpMethod as UndiciHttpMethod } from 'undici/types/dispatcher';
8
+ import type { HttpClientResponse } from './Response';
9
+ export declare type HttpMethod = UndiciHttpMethod;
10
+ export declare type RequestURL = string | URL;
11
+ export declare type FixJSONCtlCharsHandler = (data: string) => string;
12
+ export declare type FixJSONCtlChars = boolean | FixJSONCtlCharsHandler;
13
+ export declare type RequestOptions = {
14
+ /** Request method, defaults to GET. Could be GET, POST, DELETE or PUT. Alias 'type'. */
15
+ method?: HttpMethod | Lowercase<HttpMethod>;
16
+ /** Data to be sent. Will be stringify automatically. */
17
+ data?: any;
18
+ /** Manually set the content of payload. If set, data will be ignored. */
19
+ content?: string | Buffer | Readable;
20
+ /**
21
+ * @deprecated
22
+ * Stream to be pipe to the remote. If set, data and content will be ignored.
23
+ * Alias to `content = Readable`
24
+ */
25
+ stream?: Readable;
26
+ /**
27
+ * A writable stream to be piped by the response stream.
28
+ * Responding data will be write to this stream and callback
29
+ * will be called with data set null after finished writing.
30
+ */
31
+ writeStream?: Writable;
32
+ /**
33
+ * The files will send with multipart/form-data format, base on formstream.
34
+ * If method not set, will use POST method by default.
35
+ */
36
+ files?: Array<Readable | Buffer | string> | Record<string, Readable | Buffer | string> | Readable | Buffer | string;
37
+ /** Type of request data, could be 'json'. If it's 'json', will auto set Content-Type: 'application/json' header. */
38
+ contentType?: string;
39
+ /**
40
+ * Type of response data. Could be text or json.
41
+ * If it's text, the callbacked data would be a String.
42
+ * If it's json, the data of callback would be a parsed JSON Object
43
+ * and will auto set Accept: 'application/json' header.
44
+ * Default is 'buffer'.
45
+ */
46
+ dataType?: 'text' | 'json' | 'buffer' | 'stream';
47
+ /**
48
+ * @deprecated
49
+ * Let you get the res object when request connected, default false.
50
+ * If set to true, `data` will be response readable stream.
51
+ * Alias to `dataType = 'stream'`
52
+ */
53
+ streaming?: boolean;
54
+ /**
55
+ * @deprecated
56
+ * Alias to `dataType = 'stream'`
57
+ */
58
+ customResponse?: boolean;
59
+ /** Fix the control characters (U+0000 through U+001F) before JSON parse response. Default is false. */
60
+ fixJSONCtlChars?: FixJSONCtlChars;
61
+ /** Request headers. */
62
+ headers?: IncomingHttpHeaders;
63
+ /**
64
+ * Request timeout in milliseconds for connecting phase and response receiving phase.
65
+ * Defaults to exports.
66
+ * TIMEOUT, both are 5s. You can use timeout: 5000 to tell urllib use same timeout on two phase or set them seperately such as
67
+ * timeout: [3000, 5000], which will set connecting timeout to 3s and response 5s.
68
+ */
69
+ timeout?: number | number[];
70
+ /**
71
+ * username:password used in HTTP Basic Authorization.
72
+ * Alias to `headers.authorization = xxx`
73
+ **/
74
+ auth?: string;
75
+ /** follow HTTP 3xx responses as redirects. defaults to true. */
76
+ followRedirect?: boolean;
77
+ /** The maximum number of redirects to follow, defaults to 10. */
78
+ maxRedirects?: number;
79
+ /** Format the redirect url by your self. Default is url.resolve(from, to). */
80
+ formatRedirectUrl?: (a: any, b: any) => void;
81
+ /** Before request hook, you can change every thing here. */
82
+ beforeRequest?: (...args: any[]) => void;
83
+ /** Accept `gzip, br` response content and auto decode it, default is false. */
84
+ compressed?: boolean;
85
+ /**
86
+ * @deprecated
87
+ * Alias to compressed
88
+ * */
89
+ gzip?: boolean;
90
+ /**
91
+ * @deprecated
92
+ * Enable timing or not, default is false.
93
+ * */
94
+ timing?: boolean;
95
+ /**
96
+ * Auto retry times on 5xx response, default is 0. Don't work on streaming request
97
+ * It's not supported by using retry and writeStream, because the retry request can't stop the stream which is consuming.
98
+ **/
99
+ retry?: number;
100
+ /** Wait a delay(ms) between retries */
101
+ retryDelay?: number;
102
+ /**
103
+ * Determine whether retry, a response object as the first argument.
104
+ * It will retry when status >= 500 by default. Request error is not included.
105
+ */
106
+ isRetry?: (response: HttpClientResponse) => boolean;
107
+ /** Default: `null` */
108
+ opaque?: unknown;
109
+ /**
110
+ * @deprecated
111
+ * Maybe you should use opaque instead
112
+ */
113
+ ctx?: unknown;
114
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Request.js","sourceRoot":"","sources":["../Request.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Readable } from 'stream';
4
+ import { IncomingHttpHeaders } from 'http';
5
+ export declare type HttpClientResponseMeta = {
6
+ status: number;
7
+ statusCode: number;
8
+ headers: IncomingHttpHeaders;
9
+ size: number;
10
+ aborted: boolean;
11
+ rt: number;
12
+ keepAliveSocket: boolean;
13
+ requestUrls: string[];
14
+ /**
15
+ * https://eggjs.org/en/core/httpclient.html#timing-boolean
16
+ */
17
+ timing: {
18
+ contentDownload: number;
19
+ waiting: number;
20
+ };
21
+ };
22
+ export declare type ReadableWithMeta = Readable & {
23
+ status: number;
24
+ statusCode: number;
25
+ headers: IncomingHttpHeaders;
26
+ };
27
+ export declare type HttpClientResponse = {
28
+ opaque: unknown;
29
+ data: any;
30
+ status: number;
31
+ headers: IncomingHttpHeaders;
32
+ url: string;
33
+ redirected: boolean;
34
+ requestUrls: string[];
35
+ res: ReadableWithMeta | HttpClientResponseMeta;
36
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Response.js","sourceRoot":"","sources":["../Response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { RequestOptions, RequestURL } from './Request';
2
+ export declare function request(url: RequestURL, options?: RequestOptions): Promise<import("./Response").HttpClientResponse>;
3
+ export { HttpClient } from './HttpClient';
4
+ declare const _default: {
5
+ request: typeof request;
6
+ };
7
+ export default _default;