@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
101 lines • 3.09 kB
TypeScript
import { HttpClient, DownloadProgressCallback } from '../type';
import { Fs } from '../../fs/type';
/**
* Node.js HTTP client implementation using http/https modules
* Alternative to fetch API for better compatibility
*/
export declare class NodeHttpClient implements HttpClient {
private fs;
private timeout;
private headers;
private defaultTimeout;
private defaultHeaders;
constructor(fs: Fs, timeout?: number, headers?: Record<string, string>);
/**
* Download file from URL to target path using Node.js http/https
*/
download(downloadUrl: string, targetPath: string, options?: {
onProgress?: DownloadProgressCallback;
headers?: Record<string, string>;
timeout?: number;
}): Promise<void>;
/**
* Perform GET request using Node.js http/https
*/
get(requestUrl: string, options?: {
headers?: Record<string, string>;
timeout?: number;
}): Promise<{
data: ArrayBuffer;
headers: Record<string, string>;
status: number;
}>;
}
/**
* Default HTTP client implementation using fetch API
* TypeScript replacement for Go's module download mechanism
*/
export declare class FetchHttpClient implements HttpClient {
private fs;
private timeout;
private headers;
private defaultTimeout;
private defaultHeaders;
constructor(fs: Fs, timeout?: number, headers?: Record<string, string>);
/**
* Download file from URL to target path
*/
download(url: string, targetPath: string, options?: {
onProgress?: DownloadProgressCallback;
headers?: Record<string, string>;
timeout?: number;
}): Promise<void>;
/**
* Perform GET request
*/
get(url: string, options?: {
headers?: Record<string, string>;
timeout?: number;
}): Promise<{
data: ArrayBuffer;
headers: Record<string, string>;
status: number;
}>;
/**
* Set default headers
*/
setHeaders(headers: Record<string, string>): void;
/**
* Set timeout
*/
setTimeout(timeout: number): void;
}
/**
* Creates a new HTTP client instance
*/
export declare function newHttpClient(fs: Fs, timeout?: number, headers?: Record<string, string>): HttpClient;
/**
* Mock HTTP client for testing
*/
export declare class MockHttpClient implements HttpClient {
private mockResponses;
setMockResponse(url: string, data: ArrayBuffer, status?: number, headers?: Record<string, string>): void;
download(url: string, targetPath: string, options?: {
onProgress?: DownloadProgressCallback;
headers?: Record<string, string>;
timeout?: number;
}): Promise<void>;
get(url: string, options?: {
headers?: Record<string, string>;
timeout?: number;
}): Promise<{
data: ArrayBuffer;
headers: Record<string, string>;
status: number;
}>;
}
/**
* Creates a mock HTTP client for testing
*/
export declare function newMockHttpClient(): MockHttpClient;
//# sourceMappingURL=httpclient.d.ts.map