Currently, callback functions registered via call or onHeaders can only receive the "Rook-style" request headers ("HTTP_ Variables" in the Rook README).
It would be useful if there was a way to receive the raw headers, before they were munged to become variable names, perhaps as a list of pairs of strings. That way, headers could be inspected without accounting for Rook's renaming of them.
Interested parties so far include @wch and @jeroen.
This capability raises various questions.
Questions
- What value should be used to represent raw headers?
- Shouldn't be an
env because the same header might appear multiple times. This is valid in HTTP under certain circumstances
- How should a handler be registered so that httpuv knows to pass it raw headers? And, how should that value be passed? Possibilities include:
- New
callRaw and onHeadersRaw app members that pass the handler a second argument, the raw headers value. Using in conjunction with call/onHeaders respectively is an error.
- Always add the raw headers as an attribute of the Rook
req object passed to call/onHeaders
- Problematic because attributes can contribute to object equality. Might not be backward-compatible?
- Introduces overhead we don't want to pay all the time?
- Add an
addRawRequest = TRUE (default FALSE) member to app. This would be the only member of app so far that's not a function. Causes raw header value to be added to all reqs as an attribute.
- Like above, but add the
addRawRequest = TRUE optional argument to startServer/startPipeServer instead of as app member.
- Add
req$headers
- Should this be an addition to Rook first, then httpuv?
Currently, callback functions registered via
calloronHeaderscan only receive the "Rook-style" request headers ("HTTP_ Variables" in the Rook README).It would be useful if there was a way to receive the raw headers, before they were munged to become variable names, perhaps as a list of pairs of strings. That way, headers could be inspected without accounting for Rook's renaming of them.
Interested parties so far include @wch and @jeroen.
This capability raises various questions.
Questions
envbecause the same header might appear multiple times. This is valid in HTTP under certain circumstancescallRawandonHeadersRawappmembers that pass the handler a second argument, the raw headers value. Using in conjunction withcall/onHeadersrespectively is an error.reqobject passed tocall/onHeadersaddRawRequest = TRUE(defaultFALSE) member toapp. This would be the only member ofappso far that's not a function. Causes raw header value to be added to allreqs as an attribute.addRawRequest = TRUEoptional argument tostartServer/startPipeServerinstead of asappmember.req$headers