follow-redirects 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of follow-redirects might be problematic. Click here for more details.
- package/README.md +6 -6
- package/create.js +2 -1
- package/package.json +3 -2
package/README.md
CHANGED
@@ -10,7 +10,7 @@ Drop in replacement for Nodes `http` and `https` that automatically follows redi
|
|
10
10
|
|
11
11
|
[](https://nodei.co/npm/follow-redirects/)
|
12
12
|
|
13
|
-
`follow-redirects` provides [request](https://nodejs.org/api/http.html#http_http_request_options_callback) and [get](https://nodejs.org/api/http.html#http_http_get_options_callback)
|
13
|
+
`follow-redirects` provides [request](https://nodejs.org/api/http.html#http_http_request_options_callback) and [get](https://nodejs.org/api/http.html#http_http_get_options_callback)
|
14
14
|
methods that behave identically to those found on the native [http](https://nodejs.org/api/http.html#http_http_request_options_callback) and [https](https://nodejs.org/api/https.html#https_https_request_options_callback)
|
15
15
|
modules, with the exception that they will seamlessly follow redirects.
|
16
16
|
|
@@ -48,7 +48,7 @@ https.request({
|
|
48
48
|
host: 'bitly.com',
|
49
49
|
path: '/UHfDGO',
|
50
50
|
}, function (res) {
|
51
|
-
console.log(res.fetchedUrls);
|
51
|
+
console.log(res.fetchedUrls);
|
52
52
|
// [ 'http://duckduckgo.com/robots.txt', 'http://bitly.com/UHfDGO' ]
|
53
53
|
});
|
54
54
|
```
|
@@ -56,7 +56,7 @@ https.request({
|
|
56
56
|
## Browserify Usage
|
57
57
|
|
58
58
|
Due to the way `XMLHttpRequest` works, the `browserify` versions of `http` and `https` already follow redirects.
|
59
|
-
If you are *only* targetting the browser, then this library has little value for you. If you want to write cross
|
59
|
+
If you are *only* targetting the browser, then this library has little value for you. If you want to write cross
|
60
60
|
platform code for node and the browser, `follow-redirects` provides a great solution for making the native node
|
61
61
|
modules behave the same as they do in browserified builds in the browser. To avoid bundling unnecessary code
|
62
62
|
you should tell browserify to swap out `follow-redirects` with the standard modules when bundling.
|
@@ -78,10 +78,10 @@ You can then replace `follow-redirects` in your browserify configuration like so
|
|
78
78
|
|
79
79
|
The `browserify-http` module has not kept pace with node development, and no long behaves identically to the native
|
80
80
|
module when running in the browser. If you are experiencing problems, you may want to check out
|
81
|
-
[browserify-http-2](https://www.npmjs.com/package/http-browserify-2). It is more actively maintained and
|
81
|
+
[browserify-http-2](https://www.npmjs.com/package/http-browserify-2). It is more actively maintained and
|
82
82
|
attempts to address a few of the shortcomings of `browserify-http`. In that case, your browserify config should
|
83
83
|
look something like this:
|
84
|
-
|
84
|
+
|
85
85
|
```javascript
|
86
86
|
"browser": {
|
87
87
|
"follow-redirects/http" : "browserify-http-2/http",
|
@@ -94,7 +94,7 @@ The `browserify-http` module has not kept pace with node development, and no lon
|
|
94
94
|
Pull Requests are always welcome. Please [file an issue](https://github.com/olalonde/follow-redirects/issues)
|
95
95
|
detailing your proposal before you invest your valuable time. Additional features and bug fixes should be accompanied
|
96
96
|
by tests. You can run the test suite locally with a simple `npm test` command.
|
97
|
-
|
97
|
+
|
98
98
|
## Debug Logging
|
99
99
|
|
100
100
|
`follow-redirects` uses the excellent [debug](https://www.npmjs.com/package/debug) for logging. To turn on logging
|
package/create.js
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
var url = require('url');
|
3
3
|
var debug = require('debug')('follow-redirects');
|
4
4
|
var assert = require('assert');
|
5
|
+
var consume = require('stream-consume');
|
5
6
|
|
6
7
|
module.exports = function(_nativeProtocols) {
|
7
8
|
var nativeProtocols = {};
|
@@ -40,7 +41,7 @@ module.exports = function(_nativeProtocols) {
|
|
40
41
|
|
41
42
|
// we are going to follow the redirect, but in node 0.10 we must first attach a data listener
|
42
43
|
// to consume the stream and send the 'end' event
|
43
|
-
res
|
44
|
+
consume(res);
|
44
45
|
|
45
46
|
// need to use url.resolve() in case location is a relative URL
|
46
47
|
var redirectUrl = url.resolve(fetchedUrl, res.headers.location);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "follow-redirects",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.7",
|
4
4
|
"description": "HTTP and HTTPS modules that follow redirects.",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -42,7 +42,8 @@
|
|
42
42
|
"https.js"
|
43
43
|
],
|
44
44
|
"dependencies": {
|
45
|
-
"debug": "^2.2.0"
|
45
|
+
"debug": "^2.2.0",
|
46
|
+
"stream-consume": "^0.1.0"
|
46
47
|
},
|
47
48
|
"devDependencies": {
|
48
49
|
"bluebird": "^2.9.30",
|