Permalink
Browse files

perf: skip parsing of entire "X-Forwarded-Proto" header

  • Loading branch information...
dougwilson committed Oct 10, 2017
1 parent b7817ab commit b97faff6e2aa4d34d79485fe4331cb0eec13ad57
Showing with 7 additions and 2 deletions.
  1. +1 −0 History.md
  2. +6 −2 lib/request.js
View
@@ -2,6 +2,7 @@ unreleased
==========
* Fix `TypeError` in `res.send` when given `Buffer` and `ETag` header set
* perf: skip parsing of entire `X-Forwarded-Proto` header
4.16.1 / 2017-09-29
===================
View
@@ -315,8 +315,12 @@ defineGetter(req, 'protocol', function protocol(){
// Note: X-Forwarded-Proto is normally only ever a
// single value, but this is to be safe.
proto = this.get('X-Forwarded-Proto') || proto;
return proto.split(/\s*,\s*/)[0];
var header = this.get('X-Forwarded-Proto') || proto
var index = header.indexOf(',')
return index !== -1
? header.substring(0, index).trim()
: header.trim()
});
/**

0 comments on commit b97faff

Please sign in to comment.