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:
-
options
(Object)
- Implements:
Methods
setHeadersAsString(allHeaders)
Set all headers delimited by CRLF by once
Arguments:
-
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:
-
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:
-
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:
getHeader(name) → String
Reads out a header that's already been queued but not sent to the client.
Arguments:
-
name
(String)
removeHeader(name)
Removes a header that's queued for implicit sending
Arguments:
-
name
(String)
write(data, encodingopt)
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".
- Implements:
allHeaders
(String)
UBWriter#write
for parameters
path
(String)
 New path. Should include query string if any. E.G. '/index.html?page=12'
method
(String)
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']);
name
(String)
name
(String)
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".