This commit is contained in:
2025-07-28 22:37:36 +00:00
parent bc99aa3569
commit eb2ccd8d9f
21 changed files with 228 additions and 99 deletions

View File

@@ -39,6 +39,12 @@ export class CoreRequest extends AbstractCoreRequest<types.ICoreRequestOptions,
) {
super(url, options);
this.requestDataFunc = requestDataFunc;
// Check for unsupported fetch-specific options
if (options.credentials || options.mode || options.cache || options.redirect ||
options.referrer || options.referrerPolicy || options.integrity) {
throw new Error('Fetch API specific options (credentials, mode, cache, redirect, referrer, referrerPolicy, integrity) are not supported in Node.js implementation');
}
}
/**

View File

@@ -5,7 +5,7 @@ import { CoreResponse as AbstractCoreResponse } from '../core_base/response.js';
/**
* Node.js implementation of Core Response class that provides a fetch-like API
*/
export class CoreResponse<T = any> extends AbstractCoreResponse<T> implements types.ICoreResponse<T> {
export class CoreResponse<T = any> extends AbstractCoreResponse<T> implements types.INodeResponse<T> {
private incomingMessage: plugins.http.IncomingMessage;
private bodyBufferPromise: Promise<Buffer> | null = null;

View File

@@ -4,17 +4,6 @@ import * as baseTypes from '../core_base/types.js';
// Re-export base types
export * from '../core_base/types.js';
/**
* Core request options extending Node.js RequestOptions
* Node.js RequestOptions already includes method and headers
*/
export interface ICoreRequestOptions extends plugins.https.RequestOptions {
keepAlive?: boolean;
requestBody?: any;
queryParams?: { [key: string]: string };
hardDataCuttingTimeout?: number;
}
/**
* Extended IncomingMessage with body property (legacy compatibility)
*/
@@ -23,20 +12,10 @@ export interface IExtendedIncomingMessage<T = any> extends plugins.http.Incoming
}
/**
* Core response object that provides fetch-like API with Node.js specific methods
* Node.js specific response extensions
*/
export interface ICoreResponse<T = any> extends baseTypes.IAbstractResponse<T> {
// Properties
ok: boolean;
status: number;
statusText: string;
headers: plugins.http.IncomingHttpHeaders;
url: string;
// Methods
json(): Promise<T>;
text(): Promise<string>;
arrayBuffer(): Promise<ArrayBuffer>;
export interface INodeResponse<T = any> extends baseTypes.ICoreResponse<T> {
// Node.js specific methods
stream(): NodeJS.ReadableStream;
// Legacy compatibility