Skip to content

Commit

Permalink
fix for 854
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Lehmann-Mörz authored and remmeier committed Oct 6, 2022
1 parent 931accc commit be425db
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,28 @@ public Result<HttpResponse> processAsync(HttpRequestContext requestContext) {
}
QueryContext queryContext = requestContext.getQueryContext();
return processAsync(jsonPath, method, parameters, requestDocument, queryContext)
.map(this::toHttpResponse);
.map(this::toHttpResponse)
.map(httpResp -> transferHeaders(httpResp, requestContext));
}
return resultFactory.just(buildMethodNotAllowedResponse(method));
}

private HttpResponse transferHeaders(final HttpResponse targetResponse, final HttpRequestContext requestContext) {
final HttpResponse srcResponse = requestContext.getResponse();
if (srcResponse == null) {
return targetResponse;
}

// transfer only header that are not set already
srcResponse.getHeaders().forEach((k, srcValue) -> {
final String targetValue = targetResponse.getHeader(k);
if (targetValue == null && srcValue != null) {
targetResponse.setHeader(k, srcValue);
}
});
return targetResponse;
}

private Result<HttpResponse> checkMethod(HttpRequestContext requestContext) {
String method = requestContext.getMethod();
boolean isPatch = method.equals(HttpMethod.PATCH.toString());
Expand Down

0 comments on commit be425db

Please sign in to comment.