-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-valued header support #28
Comments
it could make sense to deprecate the string version and just use the HttpHeaderValues. When Rosencrantz was started, there was no such thing, and the stdlib httpserver only worked with non repeated headers. I will have a look in the next days |
While investigating this, I found a related issue in httpcore |
That said, I don't know what to do. The reason your approach does not work is that the proc readHeaders*(s1: string, p: proc(h1: string|HttpHeaderValues): Handler): Handler = takes a proc readHeaders*(s1: string, p: (proc(h1: string): Handler) or (proc(h1: HttpHeaderValues): Handler)): Handler = which takes either a Still, this does not work. I created a branch to track this - it compiles but the test fails. I am really not sure why - it may even be a bug in |
I submitted a PR to Nim to handle repeated values nim-lang/Nim#13575 |
Ok, it turns out it was a misunderstanding on my part. Now the above procs work with repeated headers in the @chrisheller If you want, please have a look if this works for you. If so, I will document and merge this |
The readHeaders procs in Rosencrantz are currently setup to work with single-valued headers, but don't handle multi-valued headers. This can be worked around by creating a copy of readHeaders that accepts HttpHeaderValues as the parameter type (instead of string).
In the readHeaders proc in Rosencrantz, the call works because req.headers[s1] (which is an HttpHeaderValues object) gets converted to a string by the toString() converter from the standard library's httpcore module. That converter just grabs the first value for the header though. That generally works since most headers are single-valued.
I'm not sure what would be the best way to add this now though. I tried changing the signature like this, but that wouldn't compile for some reason.
Adding duplicate procs seems like the wrong way to deal with it though. Maybe a macro to handle duplication might work; I haven't tried that though.
The text was updated successfully, but these errors were encountered: