Socket
Socket
Sign inDemoInstall

node-fetch

Package Overview
Dependencies
4
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.0 to 1.5.1

4

CHANGELOG.md

@@ -8,2 +8,6 @@

## v1.5.1 (master)
- Fix: redirect mode `manual` should work even when there is no redirection or broken redirection
## v1.5.0 (master)

@@ -10,0 +14,0 @@

2

index.js

@@ -178,3 +178,3 @@

// normalize location header for manual redirect mode
if (options.redirect === 'manual') {
if (options.redirect === 'manual' && headers.has('location')) {
headers.set('location', resolve_url(options.url, headers.get('location')));

@@ -181,0 +181,0 @@ }

{
"name": "node-fetch",
"version": "1.5.0",
"version": "1.5.1",
"description": "A light-weight module that brings window.fetch to node.js and io.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -149,3 +149,3 @@

default values are shown, note that only `method`, `headers` and `body` are allowed in `window.fetch`, others are node.js extensions.
default values are shown, note that only `method`, `headers`, `redirect` and `body` are allowed in `window.fetch`, others are node.js extensions.

@@ -155,9 +155,10 @@ ```

method: 'GET'
, headers: {} // request header, format {a:1} or {b:[1,2,3]}
, follow: 20 // maximum redirect count, 0 to not follow redirect
, timeout: 0 // req/res timeout in ms, 0 to disable, timeout reset on redirect
, compress: true // support gzip/deflate content encoding, false to disable
, size: 0 // maximum response body size in bytes, 0 to disable
, body: empty // request body, can be a string or readable stream
, agent: null // http.Agent instance, allows custom proxy, certificate etc.
, headers: {} // request header. format {a:'1'} or {b:['1','2','3']}
, redirect: 'follow' // set to 'manual' to extract redirect headers, `error` to reject redirect
, follow: 20 // maximum redirect count. 0 to not follow redirect
, timeout: 0 // req/res timeout in ms. 0 to disable (os limit still applies), timeout reset on redirect
, compress: true // support gzip/deflate content encoding. false to disable
, size: 0 // maximum response body size in bytes. 0 to disable
, body: empty // request body. can be a string, buffer, readable stream
, agent: null // http.Agent instance, allows custom proxy, certificate etc.
}

@@ -164,0 +165,0 @@ ```

@@ -307,3 +307,3 @@

return fetch(url, opts).then(function(res) {
expect(res.url).to.equal(base + '/redirect/301');
expect(res.url).to.equal(url);
expect(res.status).to.equal(301);

@@ -324,2 +324,14 @@ expect(res.headers.get('location')).to.equal(base + '/inspect');

it('should support redirect mode, manual flag when there is no redirect', function() {
url = base + '/hello';
opts = {
redirect: 'manual'
};
return fetch(url, opts).then(function(res) {
expect(res.url).to.equal(url);
expect(res.status).to.equal(200);
expect(res.headers.get('location')).to.be.null;
});
});
it('should follow redirect code 301 and keep existing headers', function() {

@@ -345,2 +357,14 @@ url = base + '/redirect/301';

it('should not reject broken redirect under manual redirect', function() {
url = base + '/error/redirect';
opts = {
redirect: 'manual'
};
return fetch(url, opts).then(function(res) {
expect(res.url).to.equal(url);
expect(res.status).to.equal(301);
expect(res.headers.get('location')).to.be.null;
});
});
it('should handle client-error response', function() {

@@ -347,0 +371,0 @@ url = base + '/error/400';

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc