Prevent duplicate headers in linked data bridge responses
Instead of just copying the headers received in the response from the
node to the response sent to the client, we choose the header added by
the owner webapp if there is a header name clash.
@@ -237,10 +237,10 @@ public class BridgeForLinkedDataController implements InitializingBean {
for (String headerName : fromHeaders.keySet()) {
for (String headerValue : fromHeaders.get(headerName)) {
- if ((headerName != "Transfer-Encoding") || (headerValue != "chunked")) {
+ if ((headerName != "Transfer-Encoding") || (headerValue != "chunked") && ! toResponse.containsHeader(headerName)) {
// we allow all transfer codings except chunked, because we don't do chunking
// here!
- toResponse.addHeader(headerName, headerValue);
+ toResponse.setHeader(headerName, headerValue);
}
}
}
