Skip to content

ElectronClientRequest

Unofficial

An HTTP/HTTPS request issued through the net module.

Import:

import type { ElectronClientRequest } from '@obsidian-typings/obsidian-public-latest';

Signature:

export class ElectronClientRequest

Properties

Property Type Description
chunkedEncoding boolean A boolean specifying whether the request will use HTTP chunked transfer encoding or not. The property is readable and writable, however it can be set only before the first write operation as the HTTP headers are not yet put on the wire. Trying to set the chunkedEncoding property after the first write will throw an error.

Using chunked encoding is strongly recommended if you need to send a large request body as data will be streamed in small chunks instead of being internally buffered inside Electron process memory.

Methods

Method Returns Description
abort() void Cancels an ongoing HTTP transaction. If the request has already emitted the close event, the abort operation will have no effect. Otherwise an ongoing event will emit abort and close events. Additionally, if there is an ongoing response object, it will emit the aborted event.
addListener(event, listener) this Registers a listener for the given request event.
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
end(chunk?, encoding?, callback?) void Sends the last chunk of the request data. Subsequent write or end operations will not be allowed. The finish event is emitted just after the end operation.
followRedirect() void Continues any pending redirection. Can only be called during a 'redirect' event.
getHeader(name) string The value of a previously set extra header name.
getUploadProgress() ElectronUploadProgress You can use this method in conjunction with POST requests to get the progress of a file upload or other data transfer.
on('abort', listener) this Registers a listener for the given request event.
on('close', listener) this
on('error', listener) this
on('finish', listener) this
on('login', listener) this
on('redirect', listener) this
on('response', listener) this
once(event, listener) this Registers a one-time listener for the given request event.
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
removeHeader(name) void Removes a previously set extra header name. This method can be called only before first write. Trying to call it after the first write will throw an error.
removeListener(event, listener) this Removes the given listener for the given request event.
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
setHeader(name, value) void Adds an extra HTTP header. The header name will be issued as-is without lowercasing. It can be called only before first write. Calling this method after the first write will throw an error. If the passed value is not a string, its toString() method will be called to obtain the final value.
write(chunk, encoding?, callback?) void Adds a chunk of data to the request body. The first write operation may cause the request headers to be issued on the wire. After the first write operation, it is not allowed to add or remove a custom header.

Links to this page: