- 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 errormodule:request~stdError The standard error resultmodule: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 urlString Mandatory; the request URL methodString Mandatory; the HTTP method headersObject Optional; the HTTP request headers noCompressBoolean 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 proxyObject Optional; issue the request through a HTTP proxy Properties
Name Type Description hostString The HTTP proxy host portNumber The HTTP proxy port maxRedirectsNumber Optional; the limit for the subsequent HTTP redirects in order to avoid redirect loops. Defaults to 10 if unspecified / invalid input maxBodyNumber Optional; indicates the maximum size of the buffered HTTP response body timeoutNumber 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 progressmodule:request~progress Optional; callback for tracking the request progress noUserAgentBoolean Optional; disables the default User-Agent of http-request caArray 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 noSslValidationBoolean 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 streamBoolean Optional; passes a ReadableStream back to the completion callback of a HTTP request noRedirectBoolean 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 reqBodyBuffer | 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 authObject 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 typeString The authentication type; Supported value: basic usernameString The HTTP Authentication username passwordString The HTTP Authentication password -
progress(current, total)
-
Describes the progress callback
Parameters:
Name Type Description currentNumber The current number of downloaded bytes totalNumber 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 errormodule:request~stdError The standard error or *null* on success resultmodule:request~sendResult The send result Object if the error is null - Source:
-
sendResult
-
Describes the sendResult Object
Type:
- Object
- Source:
Properties:
Name Type Description responseStream The HTTP response of node's http.request streamStream The HTTP response body. Uncompressed if it was encoded with gzip or deflate. Equal to response otherwise. urlString 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 methodString The HTTP method of the request urlString The url value passed to module:request~options codeString | Numeric | undefined The error code passed by a node.js internal binding or the HTTP status code. *undefined* otherwise headersObject | 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 methodString The HTTP method of the request codeNumber The HTTP status code headersObject The HTTP response headers responseStream The node.js [HTTP client response](http://nodejs.org/api/http.html#http_event_response) streamStream 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 requestsNumber The number of HTTP requests that were sent for getting the response urlString | undefined The final URL, only if there was a succesful redirect bufferBuffer | undefined The HTTP response body for buffered responses as [Buffer](http://nodejs.org/api/buffer.html) instance fileString | undefined The file path where the HTTP response body is saved, if applicable