Comparing version 2.0.0-next.2 to 2.0.0-next.3
@@ -15,3 +15,4 @@ function apply(src, tar) { | ||
req.timeout = opts.timeout; | ||
// IE compatible | ||
if (opts.timeout) req.timeout = opts.timeout; | ||
req.ontimeout = req.onerror = function (err) { | ||
@@ -18,0 +19,0 @@ err.timeout = err.type == 'timeout'; |
@@ -24,3 +24,6 @@ const { request } = require('https'); | ||
let req = request(opts, r => { | ||
r.setEncoding('utf8'); | ||
if (r.statusCode > 300 && redirect && r.headers.location) { | ||
opts.path = resolve(opts.path, r.headers.location); | ||
return send(method, opts.path.startsWith('/') ? opts : opts.path, opts).then(res, rej); | ||
} | ||
@@ -43,5 +46,2 @@ r.on('data', d => { | ||
toError(rej, r); | ||
} else if (r.statusCode > 300 && redirect && r.headers.location) { | ||
opts.path = resolve(opts.path, r.headers.location); | ||
return send(method, opts.path.startsWith('/') ? opts : opts.path, opts).then(res, rej); | ||
} else { | ||
@@ -48,0 +48,0 @@ res(r); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.httpie={})}(this,function(t){function e(t,e){e.headers=t.headers||{},e.statusMessage=t.statusText,e.statusCode=t.status,e.data=t.response}function n(t,n,o){return new Promise(function(s,i){var r,a,d,u;o=o||{};var p=new XMLHttpRequest,f=o.headers||{};for(r in p.timeout=o.timeout,p.ontimeout=p.onerror=function(t){t.timeout="timeout"==t.type,i(t)},p.open(t,n),p.onload=function(){for(u=p.getAllResponseHeaders().trim().split(/[\r\n]+/),e(p,p);d=u.shift();)d=d.split(": "),p.headers[d.shift().toLowerCase()]=d.join(": ");if((d=p.headers["content-type"])&&~d.indexOf("application/json"))try{p.data=JSON.parse(p.data,o.reviver)}catch(t){return e(p,t),i(t)}(p.status>=400?i:s)(p)},(a=o.body)&&/Array|Object/.test(a.constructor)&&(f["content-type"]="application/json",a=JSON.stringify(a)),f)p.setRequestHeader(r,f[r]);p.send(a)})}var o=n.bind(n,"GET"),s=n.bind(n,"POST"),i=n.bind(n,"PATCH"),r=n.bind(n,"DELETE"),a=n.bind(n,"PUT");t.del=r,t.get=o,t.patch=i,t.post=s,t.put=a,t.send=n}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.httpie={})}(this,function(t){function e(t,e){e.headers=t.headers||{},e.statusMessage=t.statusText,e.statusCode=t.status,e.data=t.response}function n(t,n,o){return new Promise(function(s,i){var r,a,d,u;o=o||{};var p=new XMLHttpRequest,f=o.headers||{};for(r in o.timeout&&(p.timeout=o.timeout),p.ontimeout=p.onerror=function(t){t.timeout="timeout"==t.type,i(t)},p.open(t,n),p.onload=function(){for(u=p.getAllResponseHeaders().trim().split(/[\r\n]+/),e(p,p);d=u.shift();)d=d.split(": "),p.headers[d.shift().toLowerCase()]=d.join(": ");if((d=p.headers["content-type"])&&~d.indexOf("application/json"))try{p.data=JSON.parse(p.data,o.reviver)}catch(t){return e(p,t),i(t)}(p.status>=400?i:s)(p)},(a=o.body)&&/Array|Object/.test(a.constructor)&&(f["content-type"]="application/json",a=JSON.stringify(a)),f)p.setRequestHeader(r,f[r]);p.send(a)})}var o=n.bind(n,"GET"),s=n.bind(n,"POST"),i=n.bind(n,"PATCH"),r=n.bind(n,"DELETE"),a=n.bind(n,"PUT");t.del=r,t.get=o,t.patch=i,t.post=s,t.put=a,t.send=n}); |
{ | ||
"name": "httpie", | ||
"version": "2.0.0-next.2", | ||
"version": "2.0.0-next.3", | ||
"repository": "lukeed/httpie", | ||
@@ -5,0 +5,0 @@ "description": "A lightweight, Promise-based wrapper for Node.js HTTP requests~!", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
210
15938