[typescript] add abort signal to requestcontext (#21323)

* add abort signal to requestcontext

* regenerate

* rebuild and regenerate

* abort signal import

* refresh samples

* clean csharp samples

* csharp sample cleanup

* add missing cs samples from master

* abort testing
This commit is contained in:
David Gamero
2025-06-17 04:45:43 -04:00
committed by GitHub
parent dbc5d09da6
commit d2b8a1eeac
34 changed files with 366 additions and 104 deletions

View File

@@ -3,6 +3,7 @@ import * as FormData from "form-data";
import { URL, URLSearchParams } from 'url';
import * as http from 'http';
import * as https from 'https';
import { AbortSignal } from "node-fetch/externals";
import { Observable, from } from '../rxjsStub';
export * from './isomorphic-fetch';
@@ -57,6 +58,7 @@ export class RequestContext {
private headers: Headers = {};
private body: RequestBody = undefined;
private url: URL;
private signal: AbortSignal | undefined = undefined;
private agent: http.Agent | https.Agent | undefined = undefined;
/**
@@ -135,6 +137,15 @@ export class RequestContext {
this.headers[key] = value;
}
public setSignal(signal: AbortSignal): void {
this.signal = signal;
}
public getSignal(): AbortSignal | undefined {
return this.signal;
}
public setAgent(agent: http.Agent | https.Agent) {
this.agent = agent;
}

View File

@@ -12,6 +12,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
method: method,
body: body as any,
headers: request.getHeaders(),
signal: request.getSignal(),
agent: request.getAgent(),
}).then((resp: any) => {
const headers: { [name: string]: string } = {};