Skip to content

http: simplify various RegExp and related checks

This PR simplifies a number of header related checks in _http_outgoing.js:

  1. http: simplify isCookieField Handrolling and checking char by char is no longer faster than just using toLowerCase and strict comparison.
  2. http: use switch in matchHeader Using a switch improves clarity of the code but also performance for all but a few edge cases which remain on par with the old code.
  3. http: simplify connection: close search

I've confirmed there is no performance regression from these tests by creating small micro benchmarks with old and new versions of these functions. All the changes should actually improve performance. That said, that wasn't the main point of this PR — readability was.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Merge request reports

Loading