ClientRequest

http~ ClientRequest

new ClientRequest(options) protected

This object is created internally and returned from http.request It represents an in-progress request whose header has already been queued. The header is still mutable using the setHeader(name, value), getHeader(name), removeHeader(name) API. The actual header will be sent along with the end().

path & method parameter is still mutable using setPath(path) & setMethod(HTTPMethod)

Arguments:
  1. options (Object)
Implements:

Methods

setHeadersAsString(allHeaders)

Set all headers delimited by CRLF by once
Arguments:
  1. allHeaders (String)

end()IncomingMessage

End request by writing a last chunk of data (optional) and send request to server. See UBWriter#write for parameters

setPath(path)

Set new path for request. Usually used during several request to the same server to avoid socket recreation.
Arguments:
  1. path (String)  New path. Should include query string if any. E.G. '/index.html?page=12'

setMethod(method)

Set new HTTP method for request. Usually used during several request to the same server to avoid socket recreation.
Arguments:
  1. method (String)

setHeader(name, value)

Sets a single header value for implicit headers. If this header already exists in the to-be-sent headers, its value will be replaced. Use an array of strings here if you need to send multiple headers with the same name

 request.setHeader('Content-Type', 'text/html');
 request.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']);
Arguments:
  1. name (String)
  2. value (String|Array)

getHeader(name)String

Reads out a header that's already been queued but not sent to the client.
Arguments:
  1. name (String)

removeHeader(name)

Removes a header that's queued for implicit sending
Arguments:
  1. name (String)

write(data, encodingopt)

Write to source.
Arguments:
  1. data (ArrayBuffer|Object|String)  Data to write. If Object - it stringify before write
  2. [encoding] (String)  Encode data to encoding before write. Default to utf-8 in case data is String or bin in case data is ArrayBuffer. One of "utf-8"|"ucs2"|"bin"|"base64".
Implements: