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

respect status code set in providers #6525

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
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 @@ -277,16 +277,27 @@ public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theReques
When we write directly to an HttpServletResponse, the invocation returns null. However, we still want to invoke
the SERVER_OUTGOING_RESPONSE pointcut.
*/

// if the response status code is set by the method, respect it. Otherwise, use the default 200.
int responseCode = Constants.STATUS_HTTP_200_OK;
if (theRequest instanceof ServletRequestDetails) {
HttpServletResponse servletResponse = ((ServletRequestDetails) theRequest).getServletResponse();
if (servletResponse != null && servletResponse.getStatus() > 0) {
responseCode = servletResponse.getStatus();
}
}

if (response == null) {
ResponseDetails responseDetails = new ResponseDetails();
responseDetails.setResponseCode(Constants.STATUS_HTTP_200_OK);
responseDetails.setResponseCode(responseCode);
callOutgoingResponseHook(theRequest, responseDetails);
return null;
} else {
Set<SummaryEnum> summaryMode = RestfulServerUtils.determineSummaryMode(theRequest);
ResponseDetails responseDetails = new ResponseDetails();
responseDetails.setResponseResource(response);
responseDetails.setResponseCode(Constants.STATUS_HTTP_200_OK);
responseDetails.setResponseCode(responseCode);

if (!callOutgoingResponseHook(theRequest, responseDetails)) {
return null;
}
Expand Down
Loading