本文整理汇总了Java中io.netty.handler.codec.http.HttpResponseStatus.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseStatus.valueOf方法的具体用法?Java HttpResponseStatus.valueOf怎么用?Java HttpResponseStatus.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.http.HttpResponseStatus
的用法示例。
在下文中一共展示了HttpResponseStatus.valueOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendHttpError
import io.netty.handler.codec.http.HttpResponseStatus; //导入方法依赖的package包/类
default void sendHttpError(ChannelHandlerContext ctx, QonduitException e) throws JsonProcessingException {
LOG.error("Error in pipeline, response code: {}, message: {}", e.getCode(), e.getMessage());
byte[] buf = JsonUtil.getObjectMapper().writeValueAsBytes(
"ResponseCode: " + e.getCode() + " Message: " + e.getMessage());
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.valueOf(e
.getCode()), Unpooled.copiedBuffer(buf));
response.headers().set(Names.CONTENT_TYPE, Constants.JSON_TYPE);
response.headers().set(Names.CONTENT_LENGTH, response.content().readableBytes());
e.getResponseHeaders().entrySet().forEach(entry -> response.headers().set(entry.getKey(), entry.getValue()));
// Send the error response
sendResponse(ctx, response);
}
示例2: HttpMessageImpl
import io.netty.handler.codec.http.HttpResponseStatus; //导入方法依赖的package包/类
public HttpMessageImpl(ChannelHandlerContext ctx, FullHttpRequest request) {
this.ctx = ctx;
this.request = request.copy();
this.param = parseQueryString(getRequestURI().toString());
this.response = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.valueOf(200));
}
示例3: HttpException
import io.netty.handler.codec.http.HttpResponseStatus; //导入方法依赖的package包/类
public HttpException(String message, int httpCode) {
this(message, HttpResponseStatus.valueOf(httpCode));
}