forked from loafle/openapi-generator-original
style(typescript): use Headers
type (#19697)
This commit is contained in:
parent
5e2af7203a
commit
36367e79e7
@ -63,6 +63,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -81,7 +83,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
{{#platforms}}
|
{{#platforms}}
|
||||||
@ -135,7 +137,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +226,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -235,8 +237,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -316,7 +318,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -33,6 +33,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -44,7 +46,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -171,8 +173,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -33,6 +33,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -44,7 +46,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -171,8 +173,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -41,6 +41,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -52,7 +54,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
private agent: http.Agent | https.Agent | undefined = undefined;
|
private agent: http.Agent | https.Agent | undefined = undefined;
|
||||||
@ -102,7 +104,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -177,8 +179,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -242,7 +244,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -33,6 +33,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -44,7 +46,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -171,8 +173,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -33,6 +33,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -44,7 +46,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -171,8 +173,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -41,6 +41,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -52,7 +54,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
private agent: http.Agent | https.Agent | undefined = undefined;
|
private agent: http.Agent | https.Agent | undefined = undefined;
|
||||||
@ -102,7 +104,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -177,8 +179,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -242,7 +244,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -32,6 +32,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -43,7 +45,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -159,8 +161,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -233,7 +235,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -32,6 +32,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -43,7 +45,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -159,8 +161,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -233,7 +235,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -41,6 +41,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -52,7 +54,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
private agent: http.Agent | https.Agent | undefined = undefined;
|
private agent: http.Agent | https.Agent | undefined = undefined;
|
||||||
@ -102,7 +104,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -177,8 +179,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -242,7 +244,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -41,6 +41,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -52,7 +54,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
private agent: http.Agent | https.Agent | undefined = undefined;
|
private agent: http.Agent | https.Agent | undefined = undefined;
|
||||||
@ -102,7 +104,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -177,8 +179,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -242,7 +244,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -33,6 +33,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -44,7 +46,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -171,8 +173,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -33,6 +33,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -44,7 +46,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -171,8 +173,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
@ -41,6 +41,8 @@ export class HttpException extends Error {
|
|||||||
*/
|
*/
|
||||||
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
type Headers = Record<string, string>;
|
||||||
|
|
||||||
function ensureAbsoluteUrl(url: string) {
|
function ensureAbsoluteUrl(url: string) {
|
||||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
return url;
|
return url;
|
||||||
@ -52,7 +54,7 @@ function ensureAbsoluteUrl(url: string) {
|
|||||||
* Represents an HTTP request context
|
* Represents an HTTP request context
|
||||||
*/
|
*/
|
||||||
export class RequestContext {
|
export class RequestContext {
|
||||||
private headers: { [key: string]: string } = {};
|
private headers: Headers = {};
|
||||||
private body: RequestBody = undefined;
|
private body: RequestBody = undefined;
|
||||||
private url: URL;
|
private url: URL;
|
||||||
private agent: http.Agent | https.Agent | undefined = undefined;
|
private agent: http.Agent | https.Agent | undefined = undefined;
|
||||||
@ -102,7 +104,7 @@ export class RequestContext {
|
|||||||
return this.httpMethod;
|
return this.httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHeaders(): { [key: string]: string } {
|
public getHeaders(): Headers {
|
||||||
return this.headers;
|
return this.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,7 @@ export class SelfDecodingBody implements ResponseBody {
|
|||||||
export class ResponseContext {
|
export class ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody
|
public body: ResponseBody
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -177,8 +179,8 @@ export class ResponseContext {
|
|||||||
* Parameter names are converted to lower case
|
* Parameter names are converted to lower case
|
||||||
* The first parameter is returned with the key `""`
|
* The first parameter is returned with the key `""`
|
||||||
*/
|
*/
|
||||||
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
public getParsedHeader(headerName: string): Headers {
|
||||||
const result: { [parameter: string]: string } = {};
|
const result: Headers = {};
|
||||||
if (!this.headers[headerName]) {
|
if (!this.headers[headerName]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -242,7 +244,7 @@ export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLib
|
|||||||
export class HttpInfo<T> extends ResponseContext {
|
export class HttpInfo<T> extends ResponseContext {
|
||||||
public constructor(
|
public constructor(
|
||||||
public httpStatusCode: number,
|
public httpStatusCode: number,
|
||||||
public headers: { [key: string]: string },
|
public headers: Headers,
|
||||||
public body: ResponseBody,
|
public body: ResponseBody,
|
||||||
public data: T,
|
public data: T,
|
||||||
) {
|
) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user