Path: blob/main/src/vs/base/parts/request/common/request.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { VSBufferReadableStream } from '../../../common/buffer.js';67const offlineName = 'Offline';89/**10* Checks if the given error is offline error11*/12export function isOfflineError(error: unknown): boolean {13if (error instanceof OfflineError) {14return true;15}16return error instanceof Error && error.name === offlineName && error.message === offlineName;17}1819export class OfflineError extends Error {20constructor() {21super(offlineName);22this.name = this.message;23}24}2526export interface IHeaders {27'Proxy-Authorization'?: string;28'x-operation-id'?: string;29'retry-after'?: string;30etag?: string;31'Content-Length'?: string;32'activityid'?: string;33'X-Market-User-Id'?: string;34[header: string]: string | string[] | undefined;35}3637export interface IRequestOptions {38type?: string;39url?: string;40user?: string;41password?: string;42headers?: IHeaders;43timeout?: number;44data?: string;45followRedirects?: number;46proxyAuthorization?: string;47/**48* A signal to not cache the response. This may not49* be supported in all implementations.50*/51disableCache?: boolean;52}5354export interface IRequestContext {55res: {56headers: IHeaders;57statusCode?: number;58};59stream: VSBufferReadableStream;60}616263