Closed illotum closed 6 years ago
I agree that header parsing and returning is a big mess. I'm not sure how to fix things without breaking backwards compatibility.
Seeing as rawHeaders
is never changed, even if rawHeadersParsed == true
I guess for your case it might work to add a RawHeaders()
method that just returns this slice.
I have a use case for dumping raw headers, exactly as they appear on the wire.
Seemingly appropriate
h.Header()
from the looks of it always returns a re-compiled slice.There is a check in
h.AppendBytes()
(used by Header()) to returnh.rawHeaders
, but it apparently never fires, I could not simulate a case whereh.rawHeadersParsed == false
. Namely, it is always getting parsed before we access it in handlers because of "Content-Length" and "Expect" peeks.(This also uncovered issue where if
DisableHeaderNamesNormalizing
server option is true, the synthesized headers have both capitalized default "User-Agent: fasthttp" and real "user-agent: string".)This is all to say, I'm looking for suggestions about how I should better add this ability. An option to enable backup copy to be stored and new method to access it? Or have it hardcoded and let Header() be the one? Will you have any objections to this feature being added in general?