Closed mruszews closed 4 years ago
Will you share the call stack? In this example the HTTP sender doesn't use anything relay specific other than the library to help format the auth header. It's very likely the error is from URLConnection class itself.
URLConnection.addRequestProperty docs state:
This method will not overwrite existing values associated with the same key.
URLConnection.setRequestProperty docs suggest that using comma separated values is the solution here when using Java's URLConnection class:
Sets the general request property. If a property with the key already exists, overwrite its value with the new value. NOTE: HTTP requires all request properties which can legally have multiple instances with the same key to use a comma-separated list syntax which enables multiple properties to be appended into a single property.
Can you try your scenario using comma separated values and not calling addRequestProperty if a value already exists?
Thanks for a quick response. Indeed coma separated values would work. However we'd like to investigate more double headers scenario.
I agree with your comment about URlConnection. Nonetheless this example doesn't exactly reflect our case. We use HybridConnectionListeners (https://github.com/Azure/azure-relay-java#creating-listeners) for communication.
Stacktrace: ==> java.io.IOException - java.lang.RuntimeException: org.eclipse.jetty.io.EofException at: HybridHttpConnection$ResponseStream.write(HybridHttpConnection.java:381)
Does it make any difference?
To clarify, you're setting the response headers in the HybridConnectionListener's requestHandler by calling context.getResponse().getHeaders().put(...)
(where context is the RelayedHttpListenerContext
) multiple times with the same key? If the keys are the same how does it hold two values for the same header name?
@bainian12345 want to take a look?
Good point. Seems like we've got an issue on our side. Let us investigate more 1-2 days, before closing this issue.
Thanks!
It's impossible to send a request or response containing multiple headers with the same name.
To replicate the issue add few lines to 'simple-http-demo' (HttpSender.java):