mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 17:47:05 +00:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 } = {};
|
||||
|
||||
Reference in New Issue
Block a user