Streaming

You can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types, in this case application/json, and use the proper content-type in the PUT request if one is not already provided in the headers.

You can also pipe() from a http.ServerRequest instance and to a http.ServerResponse instance. The HTTP method and headers will be sent as well as the entity-body data. Which means that, if you don't really care about security, you can do:

maxRedirects - the maximum number of redirects to follow, defaults to 10.

onResponse - If true the callback will be fired on the "response" event instead of "end". If a function it will be called on "response" and not effect the regular semantics of the main callback on "end".

encoding - Encoding to be used on setEncoding of response data. If set to null, the body is returned as a Buffer.

pool - A hash object containing the agents for these requests. If omitted this request will use the global pool which is set to node's default maxSockets.

pool.maxSockets - Integer containing the maximum amount of sockets in the pool.

timeout - Integer containing the number of milliseconds to wait for a request to respond before aborting the request

proxy - An HTTP proxy to be used. Support proxy Auth with Basic Auth the same way it's supported with the url parameter by embedding the auth info in the uri.

oauth - Options for OAuth HMAC-SHA1 signing, see documentation above.

strictSSL - Set to true to require that SSL certificates be valid. Note: to use your own certificate authority, you need to specify an agent that was created with that ca as an option.

jar - Set to false if you don't want cookies to be remembered for future use or define your custom cookie jar (see examples section)

The callback argument gets 3 arguments. The first is an error when applicable (usually from the http.Client option not the http.ClientRequest object). The second in an http.ClientResponse object. The third is the response body String or Buffer.

Convenience methods

There are also shorthand methods for different HTTP METHODs and some other conveniences.

request.defaults(options)

This method returns a wrapper around the normal request API that defaults to whatever options you pass in to it.