- Source:
Classes
Type Definitions
-
innerCallback(error, result)
-
Describes the completion callback of the inner wrappers module:request~Request#saveBuffer and module:request~Request#saveFile
Parameters:
Name Type Description error
module:request~stdError The standard error result
module:request~stdResult The standard result. If you wrap module:request~Request#saveBuffer or module:request~Request#saveFile by yourself, you have to use the result passed to innerCallback instead of calling module:request~Request#stdResult for consistent results. When the request is reissued for a plain resource due to gzip or deflate decoding errors a new module:request~Request object is created internally in order to keep things simpler for requests that respond with success, but break when decoded. saveBuffer and saveFile use a simple recursive logic in this particular case - Source:
-
options
-
Describes the options Object passed to the module:request~Request constructor
Type:
- Object
- Source:
Properties:
Name Type Description url
String Mandatory; the request URL method
String Mandatory; the HTTP method headers
Object Optional; the HTTP request headers noCompress
Boolean Optional; disables the Accept-Encoding HTTP request header. You may leave this job to the library itself. In case of gzip / deflate decoding errors, the request is transparently reissued with the options.noCompress flag proxy
Object Optional; issue the request through a HTTP proxy Properties
Name Type Description host
String The HTTP proxy host port
Number The HTTP proxy port maxRedirects
Number Optional; the limit for the subsequent HTTP redirects in order to avoid redirect loops. Defaults to 10 if unspecified / invalid input maxBody
Number Optional; indicates the maximum size of the buffered HTTP response body timeout
Number Optional; indicates the underlying [socket timeout](http://nodejs.org/docs/latest/api/net.html#net_socket_settimeout_timeout_callback) value in miliseconds. Defaults to 60 seconds progress
module:request~progress Optional; callback for tracking the request progress noUserAgent
Boolean Optional; disables the default User-Agent of http-request ca
Array Optional; supply your own Certificate Authority information. It *appends* your certificate(s) to the bundled list by defining the [ca of tls.connect()](http://nodejs.org/api/tls.html#tls_tls_connect_options_callback). The node.js standard behaviour is to replace the ca list noSslValidation
Boolean Optional; turns of the SSL validation. **Warning:** do this only if you know what you're doing and if you have proper reasons for doing it. Making SSL useless is not a small thing to do stream
Boolean Optional; passes a ReadableStream back to the completion callback of a HTTP request noRedirect
Boolean Optional; turns off the HTTP redirects. Passes back the headers and body of the redirect response. Adds a couple of response headers which indicate the redirection target: redirect-to-url - which indicates the target URL for the redirect as the location header might be a relative path, and redirect-to-host if there's a specified host header in the request reqBody
Buffer | Stream Optional; the contents of the request body for PUT, POST, etc. requests. Must be a Buffer or a Readable Stream instance. For Buffers, the content-length is Buffer.length. For a Readable Stream you must pass a content-length header, unless you're building a POST request with the [form-data](https://github.com/felixge/node-form-data) module. The library makes no assumptions about the content-type header, unless you're building a form with form-data auth
Object Optional; an Object that contains the authentication information. Currently it only implements HTTP Basic Authentication. The HTTP Basic Authentication was already supported by passing the username:password to the URL itself. This option provides a more API-friendly approach and it adds the basics for implementing HTTP Digest Authentication. Properties
Name Type Description type
String The authentication type; Supported value: basic username
String The HTTP Authentication username password
String The HTTP Authentication password -
progress(current, total)
-
Describes the progress callback
Parameters:
Name Type Description current
Number The current number of downloaded bytes total
Number The total number of bytes to download or 0 for chunked responses - Source:
-
sendCallback(error, result)
-
Describes the completion callback of the send method
Parameters:
Name Type Description error
module:request~stdError The standard error or *null* on success result
module:request~sendResult The send result Object if the error is null - Source:
-
sendResult
-
Describes the sendResult Object
Type:
- Object
- Source:
Properties:
Name Type Description response
Stream The HTTP response of node's http.request stream
Stream The HTTP response body. Uncompressed if it was encoded with gzip or deflate. Equal to response otherwise. url
String Optional, passed if there was a HTTP redirect. Contains the URL of the resource that returned a succesful status code. -
stdError
-
Describes the standard error passed to the completion callback as instance of Error with additional properties. This packaged Error is returned only when the HTTP request was issued. If the call to a specific method fails due to various preconditions, then the passed error doesn't have the properties from below. You need to test for their existence
Type:
- Error
- Source:
Properties:
Name Type Description method
String The HTTP method of the request url
String The url value passed to module:request~options code
String | Numeric | undefined The error code passed by a node.js internal binding or the HTTP status code. *undefined* otherwise headers
Object | undefined The HTTP response headers or *undefined* if no HTTP request is issued -
stdResult
-
Describes the standard result object passed to the completion callback
Type:
- Object
- Source:
Properties:
Name Type Description method
String The HTTP method of the request code
Number The HTTP status code headers
Object The HTTP response headers response
Stream The node.js [HTTP client response](http://nodejs.org/api/http.html#http_event_response) stream
Stream The HTTP response body as [Readable Stream](http://nodejs.org/api/stream.html#stream_class_stream_readable). The actual stream is either the [HTTP client response](http://nodejs.org/api/http.html#http_event_response) or the decoded stream by [zlib.createUnzip](http://nodejs.org/api/zlib.html#zlib_zlib_createunzip_options) if the Content-Encoding response header is either gzip or deflate. 204 and 304 responses, by RFC, don't pass back a response body requests
Number The number of HTTP requests that were sent for getting the response url
String | undefined The final URL, only if there was a succesful redirect buffer
Buffer | undefined The HTTP response body for buffered responses as [Buffer](http://nodejs.org/api/buffer.html) instance file
String | undefined The file path where the HTTP response body is saved, if applicable