* HTTP status code
* @param msg
* message document body
*/
public XML sendError(int status_code, XML msg, boolean standalone) {
ThreadContext c = ThreadContext.get();
ThreadContext.getCache().remove(c.getRequestURL());
HttpServletRequest request = c.getServletRequest();
HttpServletResponse response = c.getServletResponse();
if (response.isCommitted()) {
log.warn("Response already committed, unable to send error message");
return null;
}
Response error = ThreadContext.get().getResponse();
if (error == null) {
error = new Response();
ThreadContext.get().setResponse(error);
}
String base = ThreadContext
.getBaseURL(c.getServletRequest().isSecure());
Pattern pattern = Pattern.compile("https?://([^:/]*).*");
Matcher matcher = pattern.matcher(base);
String host = request.getServerName();
if (matcher.find()) {
host = matcher.group(1);