本文整理汇总了Java中io.netty.handler.codec.DecoderResult.isSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java DecoderResult.isSuccess方法的具体用法?Java DecoderResult.isSuccess怎么用?Java DecoderResult.isSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.DecoderResult
的用法示例。
在下文中一共展示了DecoderResult.isSuccess方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendDecoderResult
import io.netty.handler.codec.DecoderResult; //导入方法依赖的package包/类
private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
DecoderResult result = o.getDecoderResult();
if (result.isSuccess()) {
return;
}
buf.append(".. WITH DECODER FAILURE: ");
buf.append(result.cause());
buf.append("\r\n");
}
示例2: channelRead0
import io.netty.handler.codec.DecoderResult; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest httpRequest) throws Exception {
DecoderResult result = httpRequest.decoderResult();
if (!result.isSuccess()) {
throw new BadRequestException(result.cause());
}
logger.info("Get search request: " + httpRequest.uri());
// only decode get path is enough
Map<String, List<String>> requestParameters;
QueryStringDecoder stringDecoder = new QueryStringDecoder(httpRequest.uri());
requestParameters = stringDecoder.parameters();
QueryMeta meta = new QueryMeta();
for(Map.Entry<String, List<String>> entry : requestParameters.entrySet()) {
if (entry.getKey().equals("options[]")) {
// add filters
List<String> filters = entry.getValue();
filters.forEach(filter -> {
String[] typeVal = filter.split(":");
meta.addMeta(typeVal[0], typeVal[1]);
});
} else if (entry.getKey().equals("orderby")) {
meta.setOrderBy(entry.getValue().get(0));
} else {
logger.warn("Unknown query parameter, ignore it:" + entry.toString());
}
}
DecodedSearchRequest searchRequest = new DecodedSearchRequest(httpRequest, meta, orderNumber++);
ctx.fireChannelRead(searchRequest);
}
示例3: appendDecoderResult
import io.netty.handler.codec.DecoderResult; //导入方法依赖的package包/类
private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
DecoderResult result = o.decoderResult();
if (result.isSuccess()) {
return;
}
buf.append(".. WITH DECODER FAILURE: ");
buf.append(result.cause());
buf.append("\r\n");
}
示例4: appendDecoderResult
import io.netty.handler.codec.DecoderResult; //导入方法依赖的package包/类
private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
DecoderResult result = o.getDecoderResult();
if (result.isSuccess()) {
return;
}
buf.append(".. WITH DECODER FAILURE: ");
buf.append(result.cause());
buf.append("\r\n");
}
示例5: channelRead0
import io.netty.handler.codec.DecoderResult; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpObject httpObject) throws Exception {
DecoderResult result = httpObject.getDecoderResult();
if (!result.isSuccess()) {
throw new BadRequestException(result.cause());
}
Attribute<UUID> sessionUuidAttr = ctx.channel().attr(AbstractNettyServer.UUID_KEY);
if (httpObject instanceof HttpRequest) {
HttpRequest httpRequest = (HttpRequest) httpObject;
LOG.trace("Session: {} got valid HTTP request:\n{}",
sessionUuidAttr.get().toString(), httpRequest.headers().toString());
if (httpRequest.getMethod().equals(HttpMethod.POST)) {
String uri = httpRequest.getUri();
AbstractCommand cp = (AbstractCommand) commandFactory.getCommandProcessor(uri);
cp.setSessionUuid(sessionUuidAttr.get());
cp.setRequest(httpRequest);
cp.parse();
ctx.fireChannelRead(cp);
} else {
LOG.error("Got invalid HTTP method: expecting only POST");
throw new BadRequestException(
"Incorrect method " + httpRequest.getMethod().toString() + ", expected POST"
);
}
} else {
LOG.warn("Session: {} got invalid HTTP object:\n{}",
sessionUuidAttr.get().toString(), httpObject);
}
}