Added sendError(int) to HttpFacade.Response.
This commit is contained in:
parent
15828e899b
commit
7b7fbd3257
7 changed files with 51 additions and 0 deletions
|
@ -56,6 +56,7 @@ public interface HttpFacade {
|
|||
void resetCookie(String name, String path);
|
||||
void setCookie(String name, String value, String path, String domain, int maxAge, boolean secure, boolean httpOnly);
|
||||
OutputStream getOutputStream();
|
||||
void sendError(int code);
|
||||
void sendError(int code, String message);
|
||||
|
||||
/**
|
||||
|
|
|
@ -132,6 +132,13 @@ public class JaxrsHttpFacade implements OIDCHttpFacade {
|
|||
throw new IllegalStateException("Not supported yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code) {
|
||||
javax.ws.rs.core.Response response = responseBuilder.status(code).build();
|
||||
requestContext.abortWith(response);
|
||||
responseFinished = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code, String message) {
|
||||
javax.ws.rs.core.Response response = responseBuilder.status(code).entity(message).build();
|
||||
|
|
|
@ -170,6 +170,15 @@ public class JettyHttpFacade implements HttpFacade {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code) {
|
||||
try {
|
||||
response.sendError(code);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code, String message) {
|
||||
try {
|
||||
|
|
|
@ -156,6 +156,15 @@ public class ServletHttpFacade implements HttpFacade {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code) {
|
||||
try {
|
||||
response.sendError(code);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code, String message) {
|
||||
try {
|
||||
|
|
|
@ -95,6 +95,15 @@ class WrappedHttpServletResponse implements Response {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code) {
|
||||
try {
|
||||
response.sendError(code);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Unable to set HTTP status", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code, String message) {
|
||||
try {
|
||||
|
|
|
@ -167,6 +167,15 @@ public class CatalinaHttpFacade implements HttpFacade {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code) {
|
||||
try {
|
||||
response.sendError(code);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code, String message) {
|
||||
try {
|
||||
|
@ -176,6 +185,7 @@ public class CatalinaHttpFacade implements HttpFacade {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
ended = true;
|
||||
|
|
|
@ -170,6 +170,12 @@ public class UndertowHttpFacade implements HttpFacade {
|
|||
return exchange.getOutputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code) {
|
||||
exchange.setResponseCode(code);
|
||||
exchange.endExchange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int code, String message) {
|
||||
exchange.setResponseCode(code);
|
||||
|
|
Loading…
Reference in a new issue