Constructor
new httpGetRequest(options)
Properties:
| Name | Type | Description |
|---|---|---|
method |
string | GET, POST |
port |
int | port to use for localhost if no full URI is provided |
headers |
object | object with headers to pass to HTTP request, properties must be all lower case |
cookies |
object | an object with cookies to send with request, if even empty rescookies will be set in the response |
file |
string | file name where to save response, in case of error response the error body will be saved as well, it uses sync file operations |
stream |
object | a writable stream where to save data |
formdata |
object | data to be sent with the request as x-www-form-urlencoded |
postdata |
object | data to be sent with the request in the body as JSON |
postfile |
string | file to be uploaded in the POST body, not as multipart |
postsize |
int | file size to be uploaded if obtained separately |
posttype |
string | content type for post data |
multipart |
Array.<object> | an array of objects for multipart/form-data post, { name: "..", data: ".." [ file: ".."] }, for files a Buffer can be used in data |
noparse |
boolean | do not parse known content types like json, xml |
chunked |
boolean | post files using chunked encoding |
qsopts |
object | an object to be passed to |
query |
object | additional query parameters to be added to the url as an object or as encoded string |
signer |
function | a function to sign the request signer(this) |
checksum |
boolean | if true the body needs a checksum in the signature |
mtime |
Date | int | a Date or timestamp to be used in conditional requests |
conditional |
boolan | add If-Modified-Since header using |
httpTimeout |
int | timeout in milliseconds after which the request is aborted if no data received |
hardTimeout |
int | abort the request after this amount of time in ms, must be big enough to allow for all data to be received |
maxSize |
int | if the content being downloaded becomes greater than this size the request will be aborted |
retryCount |
int | how many times to retry the request on error or timeout |
retryTimeout |
int | timeout in milliseconds for retries, with every subsequent timeout it will be multiplied by |
retryOnError |
boolean | function | retry request if received non 2xx response status, if this is a function then it must return true in order to retry the request, otherwise it is treated as a boolean value, if true then retry on all non-2xx responses |
retryPrepare |
function | a function to be called before retrying, it can update any parameter, most related: _uri, retryTimeout, retryMultiplier |
errorCount |
int | how many times to retry on aborted connections, default is retryCount |
raise |
boolean | on not ok status raise and eror on return with JSON body if present or generic message |
noredirects |
boolean | if true then do not follow redirect locations for 30-[1,2,3,7] statuses |
preparse |
function | a function to be called before parsing the xml/json content, called in the context of the http object |
passheaders |
Array.<string> | a list of headers to be passed in redirects |
user |
string | authorization user, if also `password`` is provided then it will use Basic authorization, if only user is provided then Bearer |
data |
string | response data if file was not specified |
obj |
object | if the content type is a known type like json or xml this property will hold a reference to the parsed document or null in case or parse error |
status |
int | HTTP response status code |
date |
Date | Date object with the last modified time of the requested file |
resheaders |
object | response headers as an object |
rescookies |
object | parsed cookies from the response if request `cookies`` is not empty |
size |
int | size of the response body or file |
type |
string | response content type |
ok |
boolean | true if the status is between 200 and 299 |
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | properties from httpGetRequest |
Methods
parseCookies()
- Description:
Parse Set-Cookie header and return an object of cookies: { NAME: { value: VAL, secure: true, expires: N ... } }
toJSON()
- Description:
Return a simplified object for logging purposes