Skip to content
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

Headers with the same name are incorrectly overwritten and are not written at all on redirect #116

Open
ccankov opened this issue Mar 22, 2018 · 0 comments

Comments

@ccankov
Copy link

ccankov commented Mar 22, 2018

When HttpResponseMessage.write is invoked, headers with duplicate names will always be overwritten due to the current implementation of that method:

    HttpResponseMessage.setDateHeader(response)
    headers.foreach { h => response.headers.set(h.name, h.value) }

The current Netty documentation indicates that HttpHeaders.set will have this behavior:

public HttpHeaders set(java.lang.CharSequence name, java.lang.Object value)

Sets a header with the specified name and value. If there is an existing header with the same name, it is removed. If the specified value is not a String, it is converted into a String by Object.toString(), except for Date and Calendar, which are formatted to the date format defined in RFC2616.

This is true regardless of whether the headers were added using Socko's own HttpHeaders.put or HttpHeaders.append. The impact of this is that it is impossible to set multiple cookies with a single response, as one example.


In the case of redirects, the implementation of HttpResponseMessage.redirect does not write specified headers to the response, but instead defaults to only setting the date, location, keepalive, and content_length headers. This requires developers to implement their own redirect functionality in instances where it is necessary to include additional headers on a redirect response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant