felipenoris / hyper-reverse-proxy

A simple reverse proxy for use with Hyper and Tokio
Apache License 2.0
181 stars 63 forks source link

perf: remove headers inline #22

Closed somehowchris closed 2 years ago

somehowchris commented 2 years ago

Well cloing all headers isn't really a huge overhead but again I see it as a performance loss as a) mem neads to be allocated as you clone and insert and b) cycles are spent to iterate over all headers which all iterate over the HOP_HEADERS array.

So I know, duplicated code should be eliminated but in case of this I couldn't find another solution and looking at it, 2 times 3 lines of code really aint that much.

somehowchris commented 2 years ago

Updated it to also remove Connection Headers, just like in the golang one

https://cs.opensource.google/go/go/+/refs/tags/go1.18.1:src/net/http/httputil/reverseproxy.go;l=260;drc=refs%2Ftags%2Fgo1.18.1;bpv=1;bpt=1

somehowchris commented 2 years ago

Also added the Proxy-Connection Header to the hop_header list https://cs.opensource.google/go/go/+/refs/tags/go1.18.1:src/net/http/httputil/reverseproxy.go;l=178