Name: core
Owner: request
Description: HTTP Client Library
Created: 2015-12-01 09:30:28.0
Updated: 2018-03-20 17:02:33.0
Pushed: 2017-10-07 16:38:20.0
Homepage: null
Size: 196
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
HTTP Duplex Streams2 client. By default it behaves identically to Node's Core http.request method.
Each additional feature must be enabled explicitly via option. Some options requires additional dependencies.
String
url.Url
Object
String
Object
String
pass URL encoded string if you want it to be RFC3986 encoded prior sendingObject
Stream
Buffer
String
Array
Pass Object
for multipart/form-data
body:
et item
ipart: {photo: fs.createReadStream('cat.png')}
ass additional info about the uploaded item
ipart: {
oto: {
value: fs.createReadStream('cat.png'),
options: {filename: 'cat.png', contentType: 'image/png', knownLength: 22025}
ass array of values for this item
ipart: {attachments: [fs.createReadStream('cat.png'), fs.createReadStream('dog.png')]}
The item's value can be either: Stream
, Request
, Buffer
or String
.
Pass Array
for any other multipart/[TYPE]
, defaults to multipart/related
:
xample: Upload image to Google Drive
ipart: [
'Content-Type': 'application/json',
body: JSON.stringify({title: 'cat.png'})
'Content-Type': 'image/png',
body: fs.createReadStream('cat.png')
The body
key is required and reserved for setting up the item's body. It can be either: Stream
, Request
, Buffer
or String
.
Additionally you can set preambleCRLF
and/or postambleCRLF
to true
.
{user: '', pass: '', sendImmediately: false}
Authorization: Basic ...
header.sendImmediately
option default to true
if omitted.sendImmediately: false
options requires the redirect option to be enabled.{bearer: '', sendImmediately: false}
Authorization: Bearer ...
header can be set if using the bearer
option.sendImmediately
option from above applies here.gzip: true
content-encoding
response header.gzip: 'gzip'
| gzip: 'deflate'
encoding: true
utf8
.encoding: 'ISO-8859-1'
| encoding: 'win1251'
| …encoding: 'binary'
encoding
to 'binary'
when expecting binary response.true
new require('tough-cookie).CookieJar(store, options)
true
defaults to false
if omittedbuffers the response body
function(err, res, body)
by default the response buffer is decoded into string using utf8
. Set the encoding
property to binary
if you expect binary data, or any other specific encodingtrue
follow redirects for GET
, HEAD
, OPTIONS
and TRACE
requestsObject
referer
header on redirectfunction (res)
user defined function to check if the redirect should be allowedNumber
integer containing the number of milliseconds to wait for a server to send response headers (and start the response body) before aborting the request. Note that if the underlying TCP connection cannot be established, the OS-wide TCP connection timeout will overrule the timeout optionString
url.Url
Object
oxy: 'http://localhost:6767'
oxy: url.parse('http://localhost:6767')
oxy: {
url: 'http://localhost:6767',
headers: {
allow: ['header-name'],
exclusive: ['header-name']
}
true
{json: true}
accept: application/json
header for the requestJSON
or JSONP
response bodies (only if the server responds with the approprite headers){json: function () {}}
JSON.parse
method{qs: {sep:';', eq:':'}}
qs.parse
options to use{querystring: {sep:';', eq:':', options: {}}}
use the [querystring][node-querystring] module insteadquerystring.parse
options to use{qs: {sep:';', eq:':'}}
qs.stringify
options to use{querystring: {sep:';', eq:':', options: {}}}
use the [querystring][node-querystring] module insteadquerystring.stringify
options to usetrue
tries to automatically end the request on nextTick
_initialized
set when the outgoing HTTP request is fully initialized_started
set after first write/end_req
http.ClientRequest created in HTTPDuplex_res
http.IncomingMessage created in HTTPDuplex_client
http or https module_redirect
boolean indicating that the client is going to be redirected_redirected
boolean indicating that the client is been redirected at least once_src
the input read stream, usually from pipe_chunks
Array - the first chunk read from the input read stream_ended
whether the outgoing request has ended_auth
whether basic auth is being used_timeout
timeout timer instanceinit
abort
Buffer
or String
(the callback
option is required)callback
and the parse:{json:true}
options are required)followed
state variable, containing the followed redirects countsent
state variable indicating whether the Basic auth is sent alreadyheader
as a propertyRequires @request/log
method
, url
, and headers
statusCode
, statusMessage
, and headers
http.request
method@request/core
options object right before sending the requestcallback
option is being used)callback
and parse.json
options are being used)BUG=req,res node app.js
oauth: transport_method: body requires method: POST and content-type: application/x-www-form-urlencoded
oauth: signature_method: PLAINTEXT not supported with body_hash signing
This module may contain code snippets initially implemented in request by request contributors.