NanoHttpd / nanohttpd

Tiny, easily embeddable HTTP server in Java.
http://nanohttpd.org
BSD 3-Clause "New" or "Revised" License
6.89k stars 1.69k forks source link

multiple request headers with same name aren't preserved #630

Open eli-darkly opened 2 years ago

eli-darkly commented 2 years ago

This is similar to https://github.com/NanoHttpd/nanohttpd/issues/629, but on the request side, and a bit worse because it actually loses information that the client has sent. In other words, if the client sends the following headers—

my-header: value1
my-header: value2

—then session.getHeaders().get("my-header") will return only "value2". But it is legal for a client to do this (as an alternative to sending comma-delimited values), so it should be possible for the server to see what was sent.

I don't see any workaround for this in the current implementation (I mean, except to make sure the client will always send comma-delimited values instead of multiple lines, but when you're writing server code you can't necessarily control what the client will do). And I don't think I have ever seen an HTTP server framework that simply ignores multiple header lines like this; generally they provide a method for getting a list of values for any given header name.