ClientRequest

Constructors

Link copied to clipboard
constructor(options: ClientRequestConstructorOptions)

ClientRequest

constructor(options: String)

ClientRequest

Properties

Link copied to clipboard
Link copied to clipboard

A boolean specifying whether the request will use HTTP chunked transfer encoding or not. Defaults to false. 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.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val loginEvent: EventInstance<JsTuple2<AuthInfo, (username: String?, password: String?) -> Unit>>

Functions

Link copied to clipboard
fun abort()

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.

Link copied to clipboard
fun addListener(type: EventType, listener: EventListener)
Link copied to clipboard
fun emit(type: EventType, vararg args: Any?): Boolean
Link copied to clipboard
fun end()
fun end(chunk: String = definedExternally, encoding: String = definedExternally, callback: () -> Unit = definedExternally)
fun end(chunk: Buffer = definedExternally, encoding: String = definedExternally, callback: () -> Unit = definedExternally)

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.

Link copied to clipboard
Link copied to clipboard

Continues any pending redirection. Can only be called during a 'redirect' event.

Link copied to clipboard
fun getHeader(name: String): String

The value of a previously set extra header name.

Link copied to clipboard
Link copied to clipboard

You can use this method in conjunction with POST requests to get the progress of a file upload or other data transfer.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun off(type: EventType, listener: EventListener)
Link copied to clipboard
fun on(type: EventType, listener: EventListener)
Link copied to clipboard
fun once(type: EventType, listener: EventListener)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun removeHeader(name: String)

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.

Link copied to clipboard
fun removeListener(type: EventType, listener: EventListener)
Link copied to clipboard
fun setHeader(name: String, value: String)

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.

Link copied to clipboard
Link copied to clipboard
fun write(chunk: String, encoding: String = definedExternally, callback: () -> Unit = definedExternally)
fun write(chunk: Buffer, encoding: String = definedExternally, callback: () -> Unit = definedExternally)

callback is essentially a dummy function introduced in the purpose of keeping similarity with the Node.js API. It is called asynchronously in the next tick after chunk content have been delivered to the Chromium networking layer. Contrary to the Node.js implementation, it is not guaranteed that chunk content have been flushed on the wire before callback is called.