Skip to main content

Class: NodeHttpExecutor

Extends​

Constructors​

Constructor​

new NodeHttpExecutor(crossOriginHeaderPolicy?): NodeHttpExecutor

Parameters​

crossOriginHeaderPolicy?​

CrossOriginHeaderPolicy

chooses the headers each redirect to another origin sends on; the default leaves out the credential-bearing ones (see addSensitiveRedirectHeader).

Returns​

NodeHttpExecutor

Inherited from​

HttpExecutor.constructor

Properties​

crossOriginHeaderPolicy​

readonly crossOriginHeaderPolicy: CrossOriginHeaderPolicy

chooses the headers each redirect to another origin sends on; the default leaves out the credential-bearing ones (see addSensitiveRedirectHeader).

Inherited from​

HttpExecutor.crossOriginHeaderPolicy


maxRedirects​

protected readonly maxRedirects: 10 = 10

Inherited from​

HttpExecutor.maxRedirects

Methods​

addErrorAndTimeoutHandlers()​

addErrorAndTimeoutHandlers(request, reject, timeout?): void

Parameters​

request​

any

reject​

(error) => void

timeout?​

number

Returns​

void

Inherited from​

HttpExecutor.addErrorAndTimeoutHandlers


addRedirectHandlers()​

addRedirectHandlers(request, options, reject, redirectCount, handler): void

Follows the redirects of request when it reports them as events instead of 3xx responses (Electron's net with redirect: "manual", see ElectronHttpExecutor): the request is aborted and handler gets the options for the redirect target from HttpExecutor.prepareRedirectUrlOptions (with HttpExecutor.crossOriginHeaderPolicy), or reject gets the too-many-redirects error when redirectCount, the number of redirects already followed, has reached the limit. Node.js requests answer a redirect with a 3xx response, so this does nothing here.

Parameters​

request​

any

options​

ApiRequestOptions

reject​

(error) => void

redirectCount​

number

handler​

(options) => void

Returns​

void

Inherited from​

HttpExecutor.addRedirectHandlers


createMaxRedirectError()​

protected createMaxRedirectError(): Error

Returns​

Error

Inherited from​

HttpExecutor.createMaxRedirectError


createRequest()​

createRequest(options, callback): ClientRequest

Parameters​

options​

any

callback​

(response) => void

Returns​

ClientRequest

Overrides​

HttpExecutor.createRequest


doApiRequest()​

doApiRequest(options, cancellationToken, requestProcessor, redirectCount?): Promise<string>

Parameters​

options​

ApiRequestOptions

cancellationToken​

CancellationToken

requestProcessor​

(request, reject) => void

redirectCount?​

number

Returns​

Promise<string>

Inherited from​

HttpExecutor.doApiRequest


doDownload()​

protected doDownload(requestOptions, options, redirectCount): void

Parameters​

requestOptions​

ApiRequestOptions

options​

DownloadCallOptions

redirectCount​

number

Returns​

void

Inherited from​

HttpExecutor.doDownload


downloadToBuffer()​

downloadToBuffer(url, options): Promise<Buffer<ArrayBufferLike>>

Downloads url into memory: at most 500 MB, or options.maxSize bytes when that is smaller (see DownloadOptions.maxSize). A response past the limit fails the download with ERR_UPDATER_DOWNLOAD_SIZE_EXCEEDED as soon as it passes it, and its request is aborted before the rest is received.

Parameters​

url​

URL

options​

DownloadOptions

Returns​

Promise<Buffer<ArrayBufferLike>>

Inherited from​

HttpExecutor.downloadToBuffer


request()​

request(options, cancellationToken?, data?): Promise<string | null>

Parameters​

options​

ApiRequestOptions

cancellationToken?​

CancellationToken

data?​

{[name: string]: any; } | null

Returns​

Promise<string | null>

Inherited from​

HttpExecutor.request


crossOriginHeaders()​

static crossOriginHeaders(headers, ownHeaders, hop, crossOriginHeaderPolicy): OutgoingHttpHeaders

The headers to send to hop.to for a request whose headers are meant for hop.from: headers itself when to is on the same origin (see HttpExecutor.isCrossOrigin), without calling crossOriginHeaderPolicy; else the ones crossOriginHeaderPolicy returns, and the request's ownHeaders it left out. A Host header is never sent to another origin: it is removed before the policy is asked, and from what it returns, since Electron's net connects to a Host header's value instead of hop.to. Never mutates headers; what crossOriginHeaderPolicy throws fails the request. The headers are copied with filterHeaders.

Parameters​

headers​

OutgoingHttpHeaders

ownHeaders​

OutgoingHttpHeaders | null | undefined

hop​

CrossOriginHop

crossOriginHeaderPolicy​

CrossOriginHeaderPolicy

Returns​

OutgoingHttpHeaders

Inherited from​

HttpExecutor.crossOriginHeaders


isCrossOrigin()​

static isCrossOrigin(originUrl, targetUrl): boolean

Whether targetUrl is on another origin than originUrl for the purpose of sending credentials: another host, port or scheme, except an http → https upgrade of the same host on the default ports.

Parameters​

originUrl​

URL

targetUrl​

URL

Returns​

boolean

Inherited from​

HttpExecutor.isCrossOrigin


prepareRedirectUrlOptions()​

static prepareRedirectUrlOptions(redirectUrl, options, crossOriginHeaderPolicy?): ApiRequestOptions

Options for the request to redirectUrl, redirected from options. When the target is on another origin, the headers are the ones crossOriginHeaderPolicy chooses with the request's own headers added back (see HttpExecutor.crossOriginHeaders), and the auth option, which Node.js sends as an Authorization header for the original origin, is dropped. The default User-Agent and Cache-Control are set after that (see configureRequestOptions).

Parameters​

redirectUrl​

string

options​

ApiRequestOptions

crossOriginHeaderPolicy?​

CrossOriginHeaderPolicy

Returns​

ApiRequestOptions

Inherited from​

HttpExecutor.prepareRedirectUrlOptions


retryOnServerError()​

static retryOnServerError(task, maxRetries?): Promise<any>

Parameters​

task​

() => Promise<any>

maxRetries?​

number

Returns​

Promise<any>

Inherited from​

HttpExecutor.retryOnServerError