UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

68 lines 3.43 kB
/** @packageDocumentation * @module RpcInterface */ import { RpcInterface } from "../../RpcInterface"; import { RpcContentType } from "../core/RpcConstants"; import { RpcSerializedValue } from "../core/RpcMarshaling"; import { RpcRequestFulfillment, SerializedRpcRequest } from "../core/RpcProtocol"; import { RpcRequest } from "../core/RpcRequest"; import { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from "./WebAppRpcProtocol"; /** @internal */ export type HttpMethod_T = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace"; /** A web application RPC request. * @internal */ export declare class WebAppRpcRequest extends RpcRequest { private _loading; private _request; private _pathSuffix; private get _headers(); /** The maximum size permitted for an encoded component in a URL. * Note that some backends limit the total cumulative request size. Our current node backends accept requests with a max size of 16 kb. * In addition to the url size, an authorization header may also add considerably to the request size. * @note This is used for features like encoding the payload of a cacheable request in the URL. */ static maxUrlComponentSize: number; /** The HTTP method for this request. */ method: HttpMethod_T; /** Convenience access to the protocol of this request. */ readonly protocol: WebAppRpcProtocol; /** Standardized access to metadata about the request (useful for purposes such as logging). */ metadata: { status: number; message: string; }; /** Parses a request. */ static parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest>; /** Sends the response for a web request. */ static sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse): Promise<void>; /** Determines the most efficient transport type for an RPC value. */ static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType; /** Constructs a web application request. */ constructor(client: RpcInterface, operation: string, parameters: any[]); /** Sets request header values. */ protected setHeader(name: string, value: string): void; /** Sends the request. */ protected send(): Promise<number>; protected computeRetryAfter(attempts: number): number; protected handleUnknownResponse(code: number): void; protected load(): Promise<RpcSerializedValue>; /** Override to supply an alternate fetch function. */ protected supplyFetch(): typeof fetch; /** Override to supply an alternate Request function. */ protected supplyRequest(): typeof Request; private performFetch; private loadText; private loadBinary; private loadMultipart; private setupTransport; private setupBinaryTransport; private setupMultipartTransport; private setupTextTransport; /** @internal */ static backend: { sendResponse: (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse) => Promise<void>; parseRequest: (_protocol: WebAppRpcProtocol, _req: HttpServerRequest) => Promise<SerializedRpcRequest>; }; } //# sourceMappingURL=WebAppRpcRequest.d.ts.map