@opra/client
Version:
Opra Client package
45 lines (44 loc) • 2.03 kB
TypeScript
import { type URLSearchParamsInit } from '@opra/common';
import { Observable } from 'rxjs';
import { kBackend, kContext } from './constants.js';
import { HttpBackend } from './http-backend.js';
import { HttpRequestObservable } from './http-request-observable.js';
import { HttpResponse } from './http-response.js';
/**
*
* @class HttpBundleObservable
*/
export declare class HttpBundleObservable<TRequestOptions = {}> extends Observable<HttpResponse[]> {
[kBackend]: HttpBackend;
[kContext]: {
requests: HttpRequestObservable<any>[];
method: string;
url: URL;
headers: Headers;
[key: string]: any;
};
constructor(backend: HttpBackend, requests: HttpRequestObservable<any>[], init?: Pick<HttpBackend.RequestInit, 'headers'>);
options(options: TRequestOptions): HttpBundleObservable<TRequestOptions>;
header(headers: HeadersInit): this;
header(name: string, value?: string | number | boolean | null): this;
param(params: URLSearchParamsInit | Record<string, string | number | boolean | Date>): this;
param(name: string, value: any): this;
getResponses(): Promise<HttpResponse[]>;
/**
* Parses a multipart/mixed body buffer into individual parts using multipasta,
* invoking `onPart` as soon as each part is fully read rather than buffering
* the whole set. Each part contains its headers (lowercased keys) and raw
* body buffer. The stream-based approach handles large payloads without
* buffering the entire response in memory at once.
*/
protected _parseMultipartParts(buf: Buffer, contentTypeHeader: string, onPart: (part: {
headers: Record<string, string>;
body: Buffer;
}) => void): Promise<void>;
/**
* Parses a raw HTTP/1.1 response buffer into an {@link HttpResponse} using
* `@browsery/http-parser`, mirroring the server-side request parsing in
* `@opra/http`'s `IncomingMessageHost.from()`.
*/
protected _parseRawHttpResponse(buf: Buffer): HttpResponse;
}