# new ClientRequest (oObject)

Arguments:

Methods

# end () → IncomingMessage instance

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

# getHeader (nameString) → String instance

Reads out a header that's already been queued but not sent to the client.

Arguments:

# removeHeader (nameString) instance

Removes a header that's queued for implicit sending

Arguments:

# setHeader (nameString, valueString) instance

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:

# setHeadersAsString (allHeadersString) instance

Set all headers delimited by CRLF by once

Arguments:

# setMethod (methodString) instance

Set new HTTP method for request. Usually used during several request to the same server to avoid socket recreation.

Arguments:

# setPath (pathString) instance

Set new path for request. Usually used during several request to the same server to avoid socket recreation.

Arguments:
  • path: String

    New path. Should include query string if any. E.G. '/index.html?page=12'

# write (dataArrayBuffer | Object | String, encodingoptString) instance

Write to source.

Arguments:
  • data: ArrayBuffer| Object| String

    Data to write. If Object - it stringify before write

  • 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"|"base64toBin". base64toBin applicable only if data is Buffer alike