urllib 4.4.0 → 4.5.0-beta.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/src/fetch.ts CHANGED
@@ -8,21 +8,20 @@ import {
8
8
  Agent,
9
9
  getGlobalDispatcher,
10
10
  Pool,
11
- Dispatcher,
12
11
  } from 'undici';
13
12
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
13
  // @ts-ignore
15
14
  import undiciSymbols from 'undici/lib/core/symbols.js';
16
15
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
16
  // @ts-ignore
18
- import undiciFetchSymbols from 'undici/lib/web/fetch/symbols.js';
17
+ import { getResponseState } from 'undici/lib/web/fetch/response.js';
19
18
  import {
20
19
  channels,
21
20
  ClientOptions,
22
21
  PoolStat,
23
22
  RequestDiagnosticsMessage,
24
23
  ResponseDiagnosticsMessage,
25
- UnidiciTimingInfo,
24
+ UndiciTimingInfo,
26
25
  } from './HttpClient.js';
27
26
  import {
28
27
  HttpAgent,
@@ -51,7 +50,7 @@ export type FetchDiagnosticsMessage = {
51
50
 
52
51
  export type FetchResponseDiagnosticsMessage = {
53
52
  fetch: FetchMeta;
54
- timingInfo?: UnidiciTimingInfo;
53
+ timingInfo?: UndiciTimingInfo;
55
54
  response?: Response;
56
55
  error?: Error;
57
56
  };
@@ -163,7 +162,7 @@ export class FetchFactory {
163
162
  [symbols.kEnableRequestTiming]: !!(init.timing ?? true),
164
163
  [symbols.kRequestTiming]: timing,
165
164
  // [symbols.kRequestOriginalOpaque]: originalOpaque,
166
- };
165
+ } as FetchOpaque;
167
166
  const reqMeta: RequestMeta = {
168
167
  requestId,
169
168
  url: request.url,
@@ -236,8 +235,8 @@ export class FetchFactory {
236
235
  throw e;
237
236
  }
238
237
 
239
- // get unidici internal response
240
- const state = Reflect.get(res!, undiciFetchSymbols.kState) as Dispatcher.ResponseData;
238
+ // get undici internal response
239
+ const state = getResponseState(res!);
241
240
  updateSocketInfo(socketInfo, internalOpaque /* , rawError */);
242
241
 
243
242
  urllibResponse.headers = convertHeader(res!.headers);
@@ -250,7 +249,7 @@ export class FetchFactory {
250
249
 
251
250
  channels.fetchResponse.publish({
252
251
  fetch: fetchMeta,
253
- timingInfo: (state as any).timingInfo,
252
+ timingInfo: state.timingInfo,
254
253
  response: res!,
255
254
  } as FetchResponseDiagnosticsMessage);
256
255
  channels.response.publish({