electron/lib/browser/api/net.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
876 B
TypeScript
Raw Normal View History

2023-02-20 20:57:38 +00:00
import { IncomingMessage, session } from 'electron/main';
import type { ClientRequestConstructorOptions } from 'electron/main';
import { ClientRequest } from '@electron/internal/browser/api/net-client-request';
2023-02-20 20:57:38 +00:00
const { isOnline } = process._linkedBinding('electron_browser_net');
2016-09-21 15:35:03 +00:00
export function request (options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) {
2016-09-29 13:24:28 +00:00
return new ClientRequest(options, callback);
}
2023-02-20 20:57:38 +00:00
export function fetch (input: RequestInfo, init?: RequestInit): Promise<Response> {
return session.defaultSession.fetch(input, init);
}
2023-05-02 07:53:00 +00:00
export function resolveHost (host: string, options?: Electron.ResolveHostOptions): Promise<Electron.ResolvedHost> {
return session.defaultSession.resolveHost(host, options);
}
exports.isOnline = isOnline;
Object.defineProperty(exports, 'online', {
get: () => isOnline()
});