ClientRequest
Properties
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.
Functions
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.
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.
Continues any pending redirection. Can only be called during a 'redirect'
event.
You can use this method in conjunction with POST
requests to get the progress of a file upload or other data transfer.
Emitted when the request
is aborted. The abort
event will not be fired if the request
is already closed.
Emitted as the last event in the HTTP request-response transaction. The close
event indicates that no more events will be emitted on either the request
or response
objects.
Emitted when the net
module fails to issue a network request. Typically when the request
object emits an error
event, a close
event will subsequently follow and no response object will be provided.
Emitted just after the last chunk of the request
's data has been written into the request
object.
Emitted when an authenticating proxy is asking for user credentials.
Emitted when the server returns a redirect response (e.g. 301 Moved Permanently). Calling request.followRedirect
will continue with the redirection. If this event is handled, request.followRedirect
must be called synchronously, otherwise the request will be cancelled.
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.
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.
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.