agentHostRequestService.ts ×12

Frontier kind: Code frontier

unlabeled · c_10357f2f2708

4 tests · 12757 LOC · 68 files · introduces 0 tests · 46 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges46 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1927 ranges12757 lines · 68 files · Browse complete extent
All tests (intent)
4 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 46 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostRequestService.ts 46 introduced LOC · 12 ranges

Open complete file

45
46 constructor(
47 > @IConfigurationService configurationService: IConfigurationService, agentHostRequestService.ts
48 > @INativeEnvironmentService environmentService: INativeEnvironmentService,
49 > @ILogService logService: ILogService,
50 > @IAgentHostProxyResolver private readonly _proxyResolver: IAgentHostProxyResolver,
51 > ) {
52 > super('local', configurationService, environmentService, logService);
53 > }
54
55 override request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
56 > return this.logAndRequest(options, () => this._request(options, token)); agentHostRequestService.ts
57 > }
58
59 override resolveProxy(url: string): Promise<string | undefined> {
62
63 private async _request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
64 > const maxRetries = 3; agentHostRequestService.ts
65 > let lastError: Error | undefined;
66 > const isIdempotent = IDEMPOTENT_HTTP_METHODS_REGEX.test(options.type || 'GET');
67 >
68 > for (let attempt = 1; attempt <= maxRetries; attempt++) {
69 > try {
70 > return await this._requestAttempt(options, token);
71 > } catch (error) {
72 lastError = error as Error;
73 if (isCancellationError(error)) {
79 await timeout(100 * attempt, token);
80 }
82
83 throw lastError;
85
86 private async _requestAttempt(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
87 > if (token.isCancellationRequested) { agentHostRequestService.ts
88 throw new CancellationError();
89 }
91 > const cancellation = new AbortController();
92 > const cancellationListener = token.onCancellationRequested(() => cancellation.abort());
93 > const signal = options.timeout
94 ? AbortSignal.any([cancellation.signal, AbortSignal.timeout(options.timeout)])
95 > : cancellation.signal; agentHostRequestService.ts
96 >
97 > try {
98 > const response = await this._proxyResolver.fetch(options.url || '', {
99 > method: options.type || 'GET',
100 > headers: getRequestHeaders(options),
101 > body: options.data,
102 > signal,
103 > cache: options.disableCache ? 'no-store' : undefined,
104 > });
105 const stream = response.body
106 ? responseBodyToStream(response.body, cancellation, cancellationListener)
107 : emptyResponseStream(cancellationListener);
109 > res: {
110 > statusCode: response.status,
111 > headers: getResponseHeaders(response),
112 > },
113 > stream,
114 > };
115 > } catch (error) {
116 cancellationListener.dispose();
117 if (error instanceof Error && error.name === 'AbortError') {
123 throw error;
124 }
126 }
127
128 > function getRequestHeaders(options: IRequestOptions): Headers | undefined { agentHostRequestService.ts
129 > if (!options.headers && !options.user && !options.password && !options.proxyAuthorization) {
130 return undefined;
131 }
141 }
142 }
143 > if (options.user || options.password) { agentHostRequestService.ts
144 headers.set('Authorization', `Basic ${btoa(`${options.user || ''}:${options.password || ''}`)}`);
145 }