update
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as types from './types.js';
|
||||
import { CoreResponse } from './response.js';
|
||||
import { CoreRequest as AbstractCoreRequest } from '../core_base/request.js';
|
||||
|
||||
// Keep-alive agents for connection pooling
|
||||
const httpAgent = new plugins.agentkeepalive.HttpAgent({
|
||||
@@ -26,30 +27,9 @@ const httpsAgentKeepAliveFalse = new plugins.agentkeepalive.HttpsAgent({
|
||||
});
|
||||
|
||||
/**
|
||||
* Core Request class that handles all HTTP/HTTPS requests
|
||||
* Node.js implementation of Core Request class that handles all HTTP/HTTPS requests
|
||||
*/
|
||||
export class CoreRequest {
|
||||
/**
|
||||
* Tests if a URL is a unix socket
|
||||
*/
|
||||
static isUnixSocket(url: string): boolean {
|
||||
const unixRegex = /^(http:\/\/|https:\/\/|)unix:/;
|
||||
return unixRegex.test(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses socket path and route from unix socket URL
|
||||
*/
|
||||
static parseUnixSocketUrl(url: string): { socketPath: string; path: string } {
|
||||
const parseRegex = /(.*):(.*)/;
|
||||
const result = parseRegex.exec(url);
|
||||
return {
|
||||
socketPath: result[1],
|
||||
path: result[2],
|
||||
};
|
||||
}
|
||||
private url: string;
|
||||
private options: types.ICoreRequestOptions;
|
||||
export class CoreRequest extends AbstractCoreRequest<types.ICoreRequestOptions, CoreResponse> {
|
||||
private requestDataFunc: ((req: plugins.http.ClientRequest) => void) | null;
|
||||
|
||||
constructor(
|
||||
@@ -57,8 +37,7 @@ export class CoreRequest {
|
||||
options: types.ICoreRequestOptions = {},
|
||||
requestDataFunc: ((req: plugins.http.ClientRequest) => void) | null = null
|
||||
) {
|
||||
this.url = url;
|
||||
this.options = options;
|
||||
super(url, options);
|
||||
this.requestDataFunc = requestDataFunc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user