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