Class: NodeHttpExecutor
Extends
HttpExecutor<ClientRequest>
Constructors
Constructor
new NodeHttpExecutor(
crossOriginHeaderPolicy?):NodeHttpExecutor
Parameters
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
Properties
crossOriginHeaderPolicy
readonlycrossOriginHeaderPolicy: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
protectedreadonlymaxRedirects:10=10
Inherited from
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
reject
(error) => void
redirectCount
number
handler
(options) => void
Returns
void
Inherited from
HttpExecutor.addRedirectHandlers
createMaxRedirectError()
protectedcreateMaxRedirectError():Error
Returns
Error
Inherited from
HttpExecutor.createMaxRedirectError
createRequest()
createRequest(
options,callback):ClientRequest
Parameters
options
any
callback
(response) => void
Returns
ClientRequest
Overrides
doApiRequest()
doApiRequest(
options,cancellationToken,requestProcessor,redirectCount?):Promise<string>
Parameters
options
cancellationToken
requestProcessor
(request, reject) => void
redirectCount?
number
Returns
Promise<string>
Inherited from
doDownload()
protecteddoDownload(requestOptions,options,redirectCount):void
Parameters
requestOptions
options
DownloadCallOptions
redirectCount
number
Returns
void
Inherited from
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
Returns
Promise<Buffer<ArrayBufferLike>>
Inherited from
request()
request(
options,cancellationToken?,data?):Promise<string|null>
Parameters
options
cancellationToken?
data?
{[name: string]: any; } | null
Returns
Promise<string | null>
Inherited from
crossOriginHeaders()
staticcrossOriginHeaders(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
crossOriginHeaderPolicy
Returns
OutgoingHttpHeaders
Inherited from
HttpExecutor.crossOriginHeaders
isCrossOrigin()
staticisCrossOrigin(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
prepareRedirectUrlOptions()
staticprepareRedirectUrlOptions(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
crossOriginHeaderPolicy?
Returns
Inherited from
HttpExecutor.prepareRedirectUrlOptions
retryOnServerError()
staticretryOnServerError(task,maxRetries?):Promise<any>
Parameters
task
() => Promise<any>
maxRetries?
number
Returns
Promise<any>