Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request

Package Overview
Dependencies
Maintainers
4
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request - npm Package Compare versions

Comparing version 2.55.0 to 2.56.0

lib/querystring.js

45

CHANGELOG.md
## Change Log
### v2.56.0 (2015/05/28)
- [#1610](https://github.com/request/request/pull/1610) Bump module dependencies (@simov)
- [#1600](https://github.com/request/request/pull/1600) Extract the querystring logic into separate module (@simov)
- [#1607](https://github.com/request/request/pull/1607) Re-generate certificates (@simov)
- [#1599](https://github.com/request/request/pull/1599) Move getProxyFromURI logic below the check for Invaild URI (#1595) (@simov)
- [#1598](https://github.com/request/request/pull/1598) Fix the way http verbs are defined in order to please intellisense IDEs (@simov, @flannelJesus)
- [#1591](https://github.com/request/request/pull/1591) A few minor fixes: (@simov)
- [#1584](https://github.com/request/request/pull/1584) Refactor test-default tests (according to comments in #1430) (@simov)
- [#1585](https://github.com/request/request/pull/1585) Fixing documentation regarding TLS options (#1583) (@mainakae)
- [#1574](https://github.com/request/request/pull/1574) Refresh the oauth_nonce on redirect (#1573) (@simov)
- [#1570](https://github.com/request/request/pull/1570) Discovered tests that weren't properly running (@seanstrom)
- [#1569](https://github.com/request/request/pull/1569) Fix pause before response arrives (@kevinoid)
- [#1558](https://github.com/request/request/pull/1558) Emit error instead of throw (@simov)
- [#1568](https://github.com/request/request/pull/1568) Fix stall when piping gzipped response (@kevinoid)
- [#1560](https://github.com/request/request/pull/1560) Update combined-stream (@apechimp)
- [#1543](https://github.com/request/request/pull/1543) Initial support for oauth_body_hash on json payloads (@simov, @aesopwolf)
- [#1541](https://github.com/request/request/pull/1541) Fix coveralls (@simov)
- [#1540](https://github.com/request/request/pull/1540) Fix recursive defaults for convenience methods (@simov)
- [#1536](https://github.com/request/request/pull/1536) More eslint style rules (@froatsnook)
- [#1533](https://github.com/request/request/pull/1533) Adding dependency status bar to README.md (@YasharF)
- [#1539](https://github.com/request/request/pull/1539) ensure the latest version of har-validator is included (@ahmadnassri)
- [#1516](https://github.com/request/request/pull/1516) forever+pool test (@devTristan)
### v2.55.0 (2015/04/05)

@@ -24,3 +47,3 @@ - [#1520](https://github.com/request/request/pull/1520) Refactor defaults (@simov)

- [#1459](https://github.com/request/request/pull/1459) Add option to time request/response cycle (including rollup of redirects) (@aaron-em)
- [#1468](https://github.com/request/request/pull/1468) Re-enable io.js/node 0.12 build (@simov, @BBB)
- [#1468](https://github.com/request/request/pull/1468) Re-enable io.js/node 0.12 build (@simov, @mikeal, @BBB)
- [#1442](https://github.com/request/request/pull/1442) Fixed the issue with strictSSL tests on 0.12 & io.js by explicitly setting a cipher that matches the cert. (@BBB, @nicolasmccurdy, @simov, @0x4139)

@@ -73,3 +96,3 @@ - [#1460](https://github.com/request/request/pull/1460) localAddress or proxy config is lost when redirecting (@simov, @0x4139)

- [#1326](https://github.com/request/request/pull/1326) Use faster container-based infrastructure on Travis (@nylen)
- [#1315](https://github.com/request/request/pull/1315) Implement rfc3986 option (@simov)
- [#1315](https://github.com/request/request/pull/1315) Implement rfc3986 option (@simov, @nylen, @apoco, @DullReferenceException, @mmalecki, @oliamb, @cliffcrosland, @LewisJEllis, @eiriksm, @poislagarde)
- [#1314](https://github.com/request/request/pull/1314) Detect urlencoded form data header via regex (@simov)

@@ -219,3 +242,3 @@ - [#1317](https://github.com/request/request/pull/1317) Improve OAuth1.0 server side flow example (@simov)

- [#1008](https://github.com/request/request/pull/1008) Moving to module instead of cutomer buffer concatenation. (@mikeal)
- [#770](https://github.com/request/request/pull/770) Added dependency badge for README file; (@timgluz)
- [#770](https://github.com/request/request/pull/770) Added dependency badge for README file; (@timgluz, @mafintosh, @lalitkapoor, @stash, @bobyrizov)
- [#1016](https://github.com/request/request/pull/1016) toJSON no longer results in an infinite loop, returns simple objects (@FredKSchott)

@@ -226,3 +249,3 @@ - [#1018](https://github.com/request/request/pull/1018) Remove pre-0.4.4 HTTPS fix (@mmalecki)

- [#999](https://github.com/request/request/pull/999) Fix fallback for browserify for optional modules. (@eiriksm)
- [#996](https://github.com/request/request/pull/996) Wrong oauth signature when multiple same param keys exist [updated] (@bengl)
- [#996](https://github.com/request/request/pull/996) Wrong oauth signature when multiple same param keys exist [updated] (@bengl, @hyjin)

@@ -304,3 +327,3 @@ ### v2.40.0 (2014/08/06)

- [#724](https://github.com/request/request/pull/724) README.md: add custom HTTP Headers example. (@tcort)
- [#719](https://github.com/request/request/pull/719) Made a comment gender neutral. (@oztu)
- [#719](https://github.com/request/request/pull/719) Made a comment gender neutral. (@unsetbit)
- [#715](https://github.com/request/request/pull/715) Request.multipart no longer crashes when header 'Content-type' present (@pastaclub)

@@ -371,6 +394,6 @@ - [#710](https://github.com/request/request/pull/710) Fixing listing in callback part of docs. (@lukasz-zak)

- [#456](https://github.com/request/request/pull/456) hawk 0.9.0 (@hueniverse)
- [#429](https://github.com/request/request/pull/429) Copy options before adding callback. (@nrn)
- [#429](https://github.com/request/request/pull/429) Copy options before adding callback. (@nrn, @nfriedly, @youurayy, @jplock, @kapetan, @landeiro, @othiym23, @mmalecki)
- [#454](https://github.com/request/request/pull/454) Destroy the response if present when destroying the request (clean merge) (@mafintosh)
- [#310](https://github.com/request/request/pull/310) Twitter Oauth Stuff Out of Date; Now Updated (@joemccann)
- [#413](https://github.com/request/request/pull/413) rename googledoodle.png to .jpg (@nfriedly)
- [#310](https://github.com/request/request/pull/310) Twitter Oauth Stuff Out of Date; Now Updated (@joemccann, @isaacs, @mscdex)
- [#413](https://github.com/request/request/pull/413) rename googledoodle.png to .jpg (@nfriedly, @youurayy, @jplock, @kapetan, @landeiro, @othiym23, @mmalecki)
- [#448](https://github.com/request/request/pull/448) Convenience method for PATCH (@mloar)

@@ -410,3 +433,3 @@ - [#444](https://github.com/request/request/pull/444) protect against double callbacks on error path (@spollack)

- [#214](https://github.com/request/request/pull/214) documenting additional behavior of json option (@jphaas)
- [#272](https://github.com/request/request/pull/272) Boundary begins with CRLF? (@elspoono)
- [#272](https://github.com/request/request/pull/272) Boundary begins with CRLF? (@elspoono, @timshadel, @naholyr, @nanodocumet, @TehShrike)
- [#284](https://github.com/request/request/pull/284) Remove stray `console.log()` call in multipart generator. (@bcherry)

@@ -422,3 +445,3 @@ - [#241](https://github.com/request/request/pull/241) Composability updates suggested by issue #239 (@polotek)

- [#261](https://github.com/request/request/pull/261) Setting 'pool' to 'false' does NOT disable Agent pooling (@timshadel)
- [#249](https://github.com/request/request/pull/249) Fix for the fix of your (closed) issue #89 where self.headers[content-length] is set to 0 for all methods (@sethbridges)
- [#249](https://github.com/request/request/pull/249) Fix for the fix of your (closed) issue #89 where self.headers[content-length] is set to 0 for all methods (@sethbridges, @polotek, @zephrax, @jeromegn)
- [#255](https://github.com/request/request/pull/255) multipart allow body === '' ( the empty string ) (@Filirom1)

@@ -467,3 +490,3 @@ - [#260](https://github.com/request/request/pull/260) fixed just another leak of 'i' (@sreuter)

- [#76](https://github.com/request/request/pull/76) Bug when a request fails and a timeout is set (@Marsup)
- [#70](https://github.com/request/request/pull/70) add test script to package.json (@isaacs)
- [#70](https://github.com/request/request/pull/70) add test script to package.json (@isaacs, @aheckmann)
- [#73](https://github.com/request/request/pull/73) Fix #71 Respect the strictSSL flag (@isaacs)

@@ -470,0 +493,0 @@ - [#69](https://github.com/request/request/pull/69) Flatten chunked requests properly (@isaacs)

@@ -59,7 +59,5 @@ // Copyright 2010-2012 Mikeal Rogers

var verbs = ['get', 'head', 'post', 'put', 'patch', 'del']
verbs.forEach(function(verb) {
function verbFunc (verb) {
var method = verb === 'del' ? 'DELETE' : verb.toUpperCase()
request[verb] = function (uri, options, callback) {
return function (uri, options, callback) {
var params = initParams(uri, options, callback)

@@ -69,4 +67,12 @@ params.method = method

}
})
}
// define like this to please codeintel/intellisense IDEs
request.get = verbFunc('get')
request.head = verbFunc('head')
request.post = verbFunc('post')
request.put = verbFunc('put')
request.patch = verbFunc('patch')
request.del = verbFunc('del')
request.jar = function (store) {

@@ -80,3 +86,3 @@ return cookies.jar(store)

function wrapRequestMethod (method, options, requester) {
function wrapRequestMethod (method, options, requester, verb) {

@@ -95,5 +101,4 @@ return function (uri, opts, callback) {

if (typeof method === 'string') {
params.method = (method === 'del' ? 'DELETE' : method.toUpperCase())
method = request[method]
if (verb) {
params.method = (verb === 'del' ? 'DELETE' : verb.toUpperCase())
}

@@ -121,3 +126,3 @@

verbs.forEach(function(verb) {
defaults[verb] = wrapRequestMethod(verb, options, requester)
defaults[verb] = wrapRequestMethod(self[verb], options, requester, verb)
})

@@ -124,0 +129,0 @@

@@ -24,3 +24,3 @@ 'use strict'

if (typeof user !== 'string' || (pass !== undefined && typeof pass !== 'string')) {
throw new Error('auth() received invalid user or password')
self.request.emit('error', new Error('auth() received invalid user or password'))
}

@@ -119,3 +119,3 @@ self.user = user

if (bearer === undefined && user === undefined) {
throw new Error('no auth mechanism defined')
self.request.emit('error', new Error('no auth mechanism defined'))
} else if (bearer !== undefined) {

@@ -141,3 +141,3 @@ authHeader = self.bearer(bearer, sendImmediately)

var authVerb = authHeader && authHeader.split(' ')[0].toLowerCase()
// debug('reauth', authVerb)
request.debug('reauth', authVerb)

@@ -144,0 +144,0 @@ switch (authVerb) {

@@ -7,3 +7,3 @@ 'use strict'

function deferMethod() {
if(typeof setImmediate === 'undefined') {
if (typeof setImmediate === 'undefined') {
return process.nextTick

@@ -10,0 +10,0 @@ }

@@ -21,3 +21,3 @@ 'use strict'

if (!parts.forEach) {
throw new Error('Argument error, options.multipart.')
self.request.emit('error', new Error('Argument error, options.multipart.'))
}

@@ -35,4 +35,4 @@

parts.forEach(function (part) {
if(typeof part.body === 'undefined') {
throw new Error('Body attribute missing in multipart.')
if (typeof part.body === 'undefined') {
self.request.emit('error', new Error('Body attribute missing in multipart.'))
}

@@ -39,0 +39,0 @@ if (isstream(part.body)) {

@@ -7,2 +7,3 @@ 'use strict'

, oauth = require('oauth-sign')
, crypto = require('crypto')

@@ -12,2 +13,3 @@

this.request = request
this.params = null
}

@@ -62,2 +64,15 @@

OAuth.prototype.buildBodyHash = function(_oauth, body) {
if (['HMAC-SHA1', 'RSA-SHA1'].indexOf(_oauth.signature_method || 'HMAC-SHA1') < 0) {
this.request.emit('error', new Error('oauth: ' + _oauth.signature_method +
' signature_method not supported with body_hash signing.'))
}
var shasum = crypto.createHash('sha1')
shasum.update(body || '')
var sha1 = shasum.digest('hex')
return new Buffer(sha1).toString('base64')
}
OAuth.prototype.concatParams = function (oa, sep, wrap) {

@@ -82,9 +97,9 @@ wrap = wrap || ''

var self = this
, request = self.request
self.params = _oauth
var uri = request.uri || {}
, method = request.method || ''
, headers = caseless(request.headers)
, body = request.body || ''
, qsLib = request.qsLib || qs
var uri = self.request.uri || {}
, method = self.request.method || ''
, headers = caseless(self.request.headers)
, body = self.request.body || ''
, qsLib = self.request.qsLib || qs

@@ -105,23 +120,27 @@ var form

if (transport === 'body' && (method !== 'POST' || contentType !== formContentType)) {
throw new Error('oauth: transport_method of \'body\' requires \'POST\' ' +
'and content-type \'' + formContentType + '\'')
self.request.emit('error', new Error('oauth: transport_method of body requires POST ' +
'and content-type ' + formContentType))
}
var oa = this.buildParams(_oauth, uri, method, query, form, qsLib)
if (!form && typeof _oauth.body_hash === 'boolean') {
_oauth.body_hash = self.buildBodyHash(_oauth, self.request.body.toString())
}
var oa = self.buildParams(_oauth, uri, method, query, form, qsLib)
switch (transport) {
case 'header':
request.setHeader('Authorization', 'OAuth ' + this.concatParams(oa, ',', '"'))
self.request.setHeader('Authorization', 'OAuth ' + self.concatParams(oa, ',', '"'))
break
case 'query':
request.path = (query ? '&' : '?') + this.concatParams(oa, '&')
self.request.path = (query ? '&' : '?') + self.concatParams(oa, '&')
break
case 'body':
request.body = (form ? form + '&' : '') + this.concatParams(oa, '&')
self.request.body = (form ? form + '&' : '') + self.concatParams(oa, '&')
break
default:
throw new Error('oauth: transport_method invalid')
self.request.emit('error', new Error('oauth: transport_method invalid'))
}

@@ -128,0 +147,0 @@ }

@@ -18,17 +18,16 @@ 'use strict'

Redirect.prototype.onRequest = function () {
Redirect.prototype.onRequest = function (options) {
var self = this
, request = self.request
if (request.maxRedirects !== undefined) {
self.maxRedirects = request.maxRedirects
if (options.maxRedirects !== undefined) {
self.maxRedirects = options.maxRedirects
}
if (typeof request.followRedirect === 'function') {
self.allowRedirect = request.followRedirect
if (typeof options.followRedirect === 'function') {
self.allowRedirect = options.followRedirect
}
if (request.followRedirect !== undefined) {
self.followRedirects = !!request.followRedirect
if (options.followRedirect !== undefined) {
self.followRedirects = !!options.followRedirect
}
if (request.followAllRedirects !== undefined) {
self.followAllRedirects = request.followAllRedirects
if (options.followAllRedirects !== undefined) {
self.followAllRedirects = options.followAllRedirects
}

@@ -38,4 +37,4 @@ if (self.followRedirects || self.followAllRedirects) {

}
if (request.removeRefererHeader !== undefined) {
self.removeRefererHeader = request.removeRefererHeader
if (options.removeRefererHeader !== undefined) {
self.removeRefererHeader = options.removeRefererHeader
}

@@ -51,3 +50,3 @@ }

var location = response.caseless.get('location')
// debug('redirect', location)
request.debug('redirect', location)

@@ -88,8 +87,8 @@ if (self.followAllRedirects) {

request.debug('redirect to', redirectTo)
// debug('redirect to', redirectTo)
// ignore any potential response body. it cannot possibly be useful
// to us at this point.
if (request._paused) {
// response.resume should be defined, but check anyway before calling. Workaround for browserify.
if (response.resume) {
response.resume()

@@ -96,0 +95,0 @@ }

@@ -10,3 +10,3 @@ {

],
"version": "2.55.0",
"version": "2.56.0",
"author": "Mikeal Rogers <mikeal.rogers@gmail.com>",

@@ -27,3 +27,3 @@ "repository": {

"bl": "~0.9.0",
"caseless": "~0.9.0",
"caseless": "~0.10.0",
"forever-agent": "~0.6.0",

@@ -34,13 +34,13 @@ "form-data": "~0.2.0",

"node-uuid": "~1.4.0",
"qs": "~2.4.0",
"qs": "~3.1.0",
"tunnel-agent": "~0.4.0",
"tough-cookie": ">=0.12.0",
"http-signature": "~0.10.0",
"oauth-sign": "~0.6.0",
"http-signature": "~0.11.0",
"oauth-sign": "~0.8.0",
"hawk": "~2.3.0",
"aws-sign2": "~0.5.0",
"stringstream": "~0.0.4",
"combined-stream": "~0.0.5",
"combined-stream": "~1.0.1",
"isstream": "~0.1.1",
"har-validator": "^1.4.0"
"har-validator": "^1.6.1"
},

@@ -55,4 +55,5 @@ "scripts": {

"browserify-istanbul": "~0.1.3",
"buffer-equal": "0.0.1",
"coveralls": "~2.11.2",
"eslint": "0.17.1",
"eslint": "0.18.0",
"function-bind": "~1.0.0",

@@ -59,0 +60,0 @@ "istanbul": "~0.3.2",

@@ -8,2 +8,3 @@

[![Coverage](https://img.shields.io/coveralls/request/request.svg?style=flat-square)](https://coveralls.io/r/request/request)
[![Dependency Status](https://img.shields.io/david/request/request.svg?style=flat-square)](https://david-dm.org/request/request)
[![Gitter](https://img.shields.io/badge/gitter-join_chat-blue.svg?style=flat-square)](https://gitter.im/request/request?utm_source=badge)

@@ -202,4 +203,3 @@

// NOTE: Advanced use-case, for normal use see 'formData' usage above
var r = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) { // ...
var r = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {...})
var form = r.form();

@@ -439,2 +439,6 @@ form.append('my_field', 'my_value');

To use [Request Body Hash](https://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html) you can either
* Manually generate the body hash and pass it as a string `body_hash: '...'`
* Automatically generate the body hash by passing `body_hash: true`
[back to top](#table-of-contents)

@@ -585,3 +589,26 @@

TLS/SSL Protocol options, such as `cert`, `key` and `passphrase`, can be
set in the `agentOptions` property of the `options` object.
set directly in `options` object, in the `agentOptions` property of the `options` object, or even in `https.globalAgent.options`. Keep in mind that, although `agentOptions` allows for a slightly wider range of configurations, the recommendend way is via `options` object directly, as using `agentOptions` or `https.globalAgent.options` would not be applied in the same way in proxied environments (as data travels through a TLS connection instead of an http/https agent).
```js
var fs = require('fs')
, path = require('path')
, certFile = path.resolve(__dirname, 'ssl/client.crt')
, keyFile = path.resolve(__dirname, 'ssl/client.key')
, caFile = path.resolve(__dirname, 'ssl/ca.cert.pem')
, request = require('request');
var options = {
url: 'https://api.some-server.com/',
cert: fs.readFileSync(certFile),
key: fs.readFileSync(keyFile),
passphrase: 'password',
ca: fs.readFileSync(caFile)
}
};
request.get(options);
```
### Using `options.agentOptions`
In the example below, we call an API requires client side SSL certificate

@@ -702,4 +729,4 @@ (in PEM format) with passphrase protected private key (in PEM format) and disable the SSLv3 protocol:

- `qs` - object containing querystring values to be appended to the `uri`
- `qsParseOptions` - object containing options to pass to the [qs.parse](https://github.com/hapijs/qs#parsing-objects) method or [querystring.parse](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_parse_str_sep_eq_options) method
- `qsStringifyOptions` - object containing options to pass to the [qs.stringify](https://github.com/hapijs/qs#stringifying) method or to the [querystring.stringify](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options) method. For example, to change the way arrays are converted to query strings pass the `arrayFormat` option with one of `indices|brackets|repeat`
- `qsParseOptions` - object containing options to pass to the [qs.parse](https://github.com/hapijs/qs#parsing-objects) method. Alternatively pass options to the [querystring.parse](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_parse_str_sep_eq_options) method using this format `{sep:';', eq:':', options:{}}`
- `qsStringifyOptions` - object containing options to pass to the [qs.stringify](https://github.com/hapijs/qs#stringifying) method. Alternatively pass options to the [querystring.stringify](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options) method using this format `{sep:';', eq:':', options:{}}`. For example, to change the way arrays are converted to query strings using the `qs` module pass the `arrayFormat` option with one of `indices|brackets|repeat`
- `useQuerystring` - If true, use `querystring` to stringify and parse

@@ -741,2 +768,3 @@ querystrings, otherwise use `qs` (default: `false`). Set this option to

- `maxRedirects` - the maximum number of redirects to follow (default: `10`)
- `removeRefererHeader` - removes the referer header when a redirect happens (default: `false`).

@@ -778,3 +806,2 @@ ---

exclusively to a tunneling proxy and not to destination.
- `removeRefererHeader` - removes the referer header when a redirect happens (default: `false`).

@@ -781,0 +808,0 @@ ---

@@ -8,4 +8,2 @@ 'use strict'

, stream = require('stream')
, qs = require('qs')
, querystring = require('querystring')
, zlib = require('zlib')

@@ -26,2 +24,3 @@ , helpers = require('./lib/helpers')

, getProxyFromURI = require('./lib/getProxyFromURI')
, Querystring = require('./lib/querystring').Querystring
, Har = require('./lib/har').Har

@@ -234,9 +233,2 @@ , Auth = require('./lib/auth').Auth

// encode rfc3986 characters
function rfc3986 (str) {
return str.replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
}
function Request (options) {

@@ -271,2 +263,3 @@ // if given the method property in options, set property explicitMethod to true

}
self._qs = new Querystring(self)
self._auth = new Auth(self)

@@ -288,2 +281,3 @@ self._oauth = new OAuth(self)

}
Request.prototype.debug = debug

@@ -348,11 +342,3 @@ Request.prototype.setupTunnel = function () {

if (!self.qsLib) {
self.qsLib = (options.useQuerystring ? querystring : qs)
}
if (!self.qsParseOptions) {
self.qsParseOptions = options.qsParseOptions
}
if (!self.qsStringifyOptions) {
self.qsStringifyOptions = options.qsStringifyOptions
}
self._qs.init(options)

@@ -418,3 +404,3 @@ debug(options)

// A URI is needed by this point, throw if we haven't been able to get one
// A URI is needed by this point, emit error if we haven't been able to get one
if (!self.uri) {

@@ -425,3 +411,3 @@ return self.emit('error', new Error('options.uri is a required argument'))

// If a string URI/URL was given, parse it into a URL object
if(typeof self.uri === 'string') {
if (typeof self.uri === 'string') {
self.uri = url.parse(self.uri)

@@ -436,3 +422,3 @@ }

// Support Unix Sockets
if(self.uri.host === 'unix') {
if (self.uri.host === 'unix') {
// Get the socket & request paths from the URL

@@ -455,11 +441,2 @@ var unixParts = self.uri.path.split(':')

if(!self.hasOwnProperty('proxy')) {
self.proxy = getProxyFromURI(self.uri)
}
self.tunnel = getTunnelOption(self, options)
if (self.proxy) {
self.setupTunnel()
}
if (!self.uri.pathname) {self.uri.pathname = '/'}

@@ -482,4 +459,13 @@

self._redirect.onRequest()
if (!self.hasOwnProperty('proxy')) {
self.proxy = getProxyFromURI(self.uri)
}
self.tunnel = getTunnelOption(self, options)
if (self.proxy) {
self.setupTunnel()
}
self._redirect.onRequest(options)
self.setHost = false

@@ -556,6 +542,2 @@ if (!self.hasHeader('host')) {

// Auth must happen last in case signing is dependent on other headers
if (options.oauth) {
self.oauth(options.oauth)
}
if (options.aws) {

@@ -594,3 +576,3 @@ self.aws(options.aws)

if (self.uri.auth && !self.hasHeader('authorization')) {
var uriAuthPieces = self.uri.auth.split(':').map(function(item){ return querystring.unescape(item) })
var uriAuthPieces = self.uri.auth.split(':').map(function(item) {return self._qs.unescape(item)})
self.auth(uriAuthPieces[0], uriAuthPieces.slice(1).join(':'), true)

@@ -600,5 +582,3 @@ }

if (!self.tunnel && self.proxy && self.proxy.auth && !self.hasHeader('proxy-authorization')) {
var proxyAuthPieces = self.proxy.auth.split(':').map(function(item){
return querystring.unescape(item)
})
var proxyAuthPieces = self.proxy.auth.split(':').map(function(item) {return self._qs.unescape(item)})
var authHeader = 'Basic ' + toBase64(proxyAuthPieces.join(':'))

@@ -643,6 +623,12 @@ self.setHeader('proxy-authorization', authHeader)

} else {
throw new Error('Argument error, options.body.')
self.emit('error', new Error('Argument error, options.body.'))
}
}
if (options.oauth) {
self.oauth(options.oauth)
} else if (self._oauth.params && self.hasHeader('authorization')) {
self.oauth(self._oauth.params)
}
var protocol = self.proxy && !self.tunnel ? self.proxy.protocol : self.uri.protocol

@@ -684,3 +670,3 @@ , defaultModules = {'http:':http, 'https:':https}

if (self.ntick && self._started) {
throw new Error('You cannot pipe to this stream after the outbound request has started.')
self.emit('error', new Error('You cannot pipe to this stream after the outbound request has started.'))
}

@@ -1066,8 +1052,2 @@ self.src = src

}
if (self._paused) {
response.pause()
} else if (response.resume) {
// response.resume should be defined, but check anyway before calling. Workaround for browserify.
response.resume()
}

@@ -1140,3 +1120,3 @@ self.response = response

var dataStream
var responseContent
if (self.gzip) {

@@ -1147,4 +1127,4 @@ var contentEncoding = response.headers['content-encoding'] || 'identity'

if (contentEncoding === 'gzip') {
dataStream = zlib.createGunzip()
response.pipe(dataStream)
responseContent = zlib.createGunzip()
response.pipe(responseContent)
} else {

@@ -1156,6 +1136,6 @@ // Since previous versions didn't check for Content-Encoding header,

}
dataStream = response
responseContent = response
}
} else {
dataStream = response
responseContent = response
}

@@ -1166,4 +1146,4 @@

console.error('Ignoring encoding parameter as this stream is being piped to another stream which makes the encoding option invalid.')
} else if (dataStream.setEncoding) {
dataStream.setEncoding(self.encoding)
} else if (responseContent.setEncoding) {
responseContent.setEncoding(self.encoding)
} else {

@@ -1173,6 +1153,12 @@ // Should only occur on node pre-v0.9.4 (joyent/node@9b5abe5) with

// If/When support for 0.9.4 is dropped, this should be unnecessary.
dataStream = dataStream.pipe(stringstream(self.encoding))
responseContent = responseContent.pipe(stringstream(self.encoding))
}
}
if (self._paused) {
responseContent.pause()
}
self.responseContent = responseContent
self.emit('response', response)

@@ -1184,13 +1170,13 @@

dataStream.on('data', function (chunk) {
responseContent.on('data', function (chunk) {
self._destdata = true
self.emit('data', chunk)
})
dataStream.on('end', function (chunk) {
responseContent.on('end', function (chunk) {
self.emit('end', chunk)
})
dataStream.on('error', function (error) {
responseContent.on('error', function (error) {
self.emit('error', error)
})
dataStream.on('close', function () {self.emit('close')})
responseContent.on('close', function () {self.emit('close')})

@@ -1236,6 +1222,8 @@ if (self.callback) {

response.body = JSON.parse(response.body, self._jsonReviver)
} catch (e) {}
} catch (e) {
// empty
}
}
debug('emitting complete', self.uri.href)
if(typeof response.body === 'undefined' && !self._json) {
if (typeof response.body === 'undefined' && !self._json) {
response.body = self.encoding === null ? new Buffer(0) : ''

@@ -1247,3 +1235,3 @@ }

//if no callback
else{
else {
self.on('end', function () {

@@ -1318,3 +1306,3 @@ if (self._aborted) {

if (!clobber && self.uri.query) {
base = self.qsLib.parse(self.uri.query, self.qsParseOptions)
base = self._qs.parse(self.uri.query)
} else {

@@ -1328,9 +1316,9 @@ base = {}

if (self.qsLib.stringify(base, self.qsStringifyOptions) === ''){
if (self._qs.stringify(base) === '') {
return self
}
var qs = self.qsLib.stringify(base, self.qsStringifyOptions)
var qs = self._qs.stringify(base)
self.uri = url.parse(self.uri.href.split('?')[0] + '?' + rfc3986(qs))
self.uri = url.parse(self.uri.href.split('?')[0] + '?' + qs)
self.url = self.uri

@@ -1346,5 +1334,4 @@ self.path = self.uri.path

self.body = (typeof form === 'string')
? form.toString('utf8')
: self.qsLib.stringify(form, self.qsStringifyOptions).toString('utf8')
self.body = rfc3986(self.body)
? self._qs.rfc3986(form.toString('utf8'))
: self._qs.stringify(form).toString('utf8')
return self

@@ -1385,3 +1372,3 @@ }

} else {
self.body = rfc3986(self.body)
self.body = self._qs.rfc3986(self.body)
}

@@ -1533,5 +1520,5 @@ if (!self.hasHeader('content-type')) {

if (self._destdata) {
throw new Error('You cannot pipe after data has been emitted from the response.')
self.emit('error', new Error('You cannot pipe after data has been emitted from the response.'))
} else if (self._ended) {
throw new Error('You cannot pipe after the response has been ended.')
self.emit('error', new Error('You cannot pipe after the response has been ended.'))
} else {

@@ -1567,6 +1554,6 @@ stream.Stream.prototype.pipe.call(self, dest, opts)

var self = this
if (!self.response) {
if (!self.responseContent) {
self._paused = true
} else {
self.response.pause.apply(self.response, arguments)
self.responseContent.pause.apply(self.responseContent, arguments)
}

@@ -1576,6 +1563,6 @@ }

var self = this
if (!self.response) {
if (!self.responseContent) {
self._paused = false
} else {
self.response.resume.apply(self.response, arguments)
self.responseContent.resume.apply(self.responseContent, arguments)
}

@@ -1582,0 +1569,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc