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

For proxied responses, we have been combining headers which we need to dedupe #189

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,15 @@ private String proxyPost(Request request, Response response) {
} catch(NullPointerException e) {
LOG.warn("Failed to read variables from GraphQL Plan request. Still passing to OTP2: {}", e.getMessage());
}

}

// provide response to requester as received from OTP server
Arrays.stream(otpDispatcherResponse.headers).forEach(header -> response.header(header.getName(), header.getValue()));
// Add response headers to requester as it was received from OTP server, but beware that
// spark.Response#header() will duplicate rather than update, so filter out duplicates.
Arrays.stream(otpDispatcherResponse.headers)
.filter(h -> !response.raw().containsHeader(h.getName()))
//.peek(h -> LOG.info("NEW {}={}", h.getName(), h.getValue()))
JymDyerIBI marked this conversation as resolved.
Show resolved Hide resolved
.forEach(h -> response.header(h.getName(), h.getValue()));

response.status(otpDispatcherResponse.statusCode);
return otpDispatcherResponse.responseBody;
}
Expand Down
Loading