Skip to content

Commit

Permalink
perf: skip parsing of entire "X-Forwarded-Proto" header
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Oct 10, 2017
1 parent b7817ab commit b97faff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
===================
Expand Down
8 changes: 6 additions & 2 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});

/**
Expand Down

0 comments on commit b97faff

Please sign in to comment.