本文整理汇总了Java中io.undertow.util.StatusCodes.BAD_REQUEST属性的典型用法代码示例。如果您正苦于以下问题:Java StatusCodes.BAD_REQUEST属性的具体用法?Java StatusCodes.BAD_REQUEST怎么用?Java StatusCodes.BAD_REQUEST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类io.undertow.util.StatusCodes
的用法示例。
在下文中一共展示了StatusCodes.BAD_REQUEST属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequest
/**
* Only allow the request through if successfully authenticated or if authentication is not required.
*
* @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange)
*/
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
if(exchange.isInIoThread()) {
exchange.dispatch(this);
return;
}
SecurityContext context = exchange.getSecurityContext();
if (context.authenticate()) {
if(!exchange.isComplete()) {
next.handleRequest(exchange);
}
} else {
if(exchange.getResponseCode() >= StatusCodes.BAD_REQUEST && !exchange.isComplete()) {
ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
src.getOriginalResponse().sendError(exchange.getResponseCode());
} else {
exchange.endExchange();
}
}
}
示例2: withBadRequest
/**
* Creates a response object with HTTP status code 400
*
* @return A response object {@link io.mangoo.routing.Response}
*/
public static Response withBadRequest() {
return new Response(StatusCodes.BAD_REQUEST);
}