follow-redirects 1.15.0 → 1.15.1

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.

Files changed (2) hide show
  1. package/index.js +14 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -274,21 +274,26 @@ RedirectableRequest.prototype._performRequest = function () {
274
274
  this._options.agent = this._options.agents[scheme];
275
275
  }
276
276
 
277
- // Create the native request
277
+ // Create the native request and set up its event handlers
278
278
  var request = this._currentRequest =
279
279
  nativeProtocol.request(this._options, this._onNativeResponse);
280
- this._currentUrl = url.format(this._options);
281
-
282
- // Set up event handlers
283
280
  request._redirectable = this;
284
- for (var e = 0; e < events.length; e++) {
285
- request.on(events[e], eventHandlers[events[e]]);
281
+ for (var event of events) {
282
+ request.on(event, eventHandlers[event]);
286
283
  }
287
284
 
285
+ // RFC7230§5.3.1: When making a request directly to an origin server, […]
286
+ // a client MUST send only the absolute path […] as the request-target.
287
+ this._currentUrl = /^\//.test(this._options.path) ?
288
+ url.format(this._options) :
289
+ // When making a request to a proxy, […]
290
+ // a client MUST send the target URI in absolute-form […].
291
+ this._currentUrl = this._options.path;
292
+
288
293
  // End a redirected request
289
294
  // (The first request must be ended explicitly with RedirectableRequest#end)
290
295
  if (this._isRedirect) {
291
- // Write the request entity and end.
296
+ // Write the request entity and end
292
297
  var i = 0;
293
298
  var self = this;
294
299
  var buffers = this._requestBodyBuffers;
@@ -576,8 +581,8 @@ function createErrorType(code, defaultMessage) {
576
581
  }
577
582
 
578
583
  function abortRequest(request) {
579
- for (var e = 0; e < events.length; e++) {
580
- request.removeListener(events[e], eventHandlers[events[e]]);
584
+ for (var event of events) {
585
+ request.removeListener(event, eventHandlers[event]);
581
586
  }
582
587
  request.on("error", noop);
583
588
  request.abort();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "follow-redirects",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "HTTP and HTTPS modules that follow redirects.",
5
5
  "license": "MIT",
6
6
  "main": "index.js",