io.netty.handler.codec.http.HttpRequest.getDecoderResult()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中io.netty.handler.codec.http.HttpRequest.getDecoderResult()方法的一些代码示例,展示了HttpRequest.getDecoderResult()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getDecoderResult()方法的具体详情如下:
包路径:io.netty.handler.codec.http.HttpRequest
类名称:HttpRequest
方法名:getDecoderResult

HttpRequest.getDecoderResult介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
@Deprecated
public DecoderResult getDecoderResult() {
  return request.getDecoderResult();
}

代码示例来源:origin: buremba/netty-rest

@Override
public DecoderResult getDecoderResult() {
  return request.getDecoderResult();
}

代码示例来源:origin: org.wisdom-framework/wisdom-engine

@Override
public DecoderResult getDecoderResult() {
  return request.getDecoderResult();
}

代码示例来源:origin: apache/activemq-artemis

@Override
@Deprecated
public DecoderResult getDecoderResult() {
  return request.getDecoderResult();
}

代码示例来源:origin: io.netty/netty-codec-http

@Override
@Deprecated
public DecoderResult getDecoderResult() {
  return request.getDecoderResult();
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

@Override
@Deprecated
public DecoderResult getDecoderResult() {
  return request.getDecoderResult();
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
@Deprecated
public DecoderResult getDecoderResult() {
  return request.getDecoderResult();
}

代码示例来源:origin: HotelsDotCom/styx

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  if (msg instanceof HttpRequest && ((HttpRequest) msg).getDecoderResult().isSuccess()) {
    requestOngoing = true;
    this.msg = msg;
  } else if (msg instanceof LastHttpContent) {
    requestOngoing = false;
  }
  super.channelRead(ctx, msg);
}

代码示例来源:origin: io.reactivex/rxnetty

isHttpRequest = true;
HttpRequest httpRequest = (HttpRequest) msg;
DecoderResult decoderResult = httpRequest.getDecoderResult();
if (decoderResult.isSuccess()) {
  eventsSubject.onEvent(HttpServerMetricsEvent.REQUEST_HEADERS_RECEIVED);

代码示例来源:origin: net.lightbody.bmp/littleproxy

/***************************************************************************
 * Reading
 **************************************************************************/
@Override
protected ConnectionState readHTTPInitial(HttpRequest httpRequest) {
  LOG.debug("Received raw request: {}", httpRequest);
  // if we cannot parse the request, immediately return a 400 and close the connection, since we do not know what state
  // the client thinks the connection is in
  if (httpRequest.getDecoderResult().isFailure()) {
    LOG.debug("Could not parse request from client. Decoder result: {}", httpRequest.getDecoderResult().toString());
    FullHttpResponse response = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1,
        HttpResponseStatus.BAD_REQUEST,
        "Unable to parse HTTP request");
    HttpHeaders.setKeepAlive(response, false);
    respondWithShortCircuitResponse(response);
    return DISCONNECT_REQUESTED;
  }
  boolean authenticationRequired = authenticationRequired(httpRequest);
  if (authenticationRequired) {
    LOG.debug("Not authenticated!!");
    return AWAITING_PROXY_AUTHENTICATION;
  } else {
    return doReadHTTPInitial(httpRequest);
  }
}

代码示例来源:origin: shuaiweili/Dubbo-Zookeeper-Netty-SpringMVC

@Override
public void messageReceived(ChannelHandlerContext ctx, HttpRequest request) throws Exception {
  if (!request.getDecoderResult().isSuccess()) {
    sendError(ctx, BAD_REQUEST);
    return;
  }
  MockHttpServletRequest servletRequest = createServletRequest(request);
  MockHttpServletResponse servletResponse = new MockHttpServletResponse();
  this.servlet.service(servletRequest, servletResponse);
  HttpResponseStatus status = HttpResponseStatus.valueOf(servletResponse.getStatus());
  HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status);
  for (String name : servletResponse.getHeaderNames()) {
    for (Object value : servletResponse.getHeaderValues(name)) {
      response.addHeader(name, value);
    }
  }
  // Write the initial line and the header.
  ctx.write(response);
  InputStream contentStream = new ByteArrayInputStream(servletResponse.getContentAsByteArray());
  // Write the content.
  ChannelFuture writeFuture = ctx.write(new ChunkedStream(contentStream));
  writeFuture.addListener(ChannelFutureListener.CLOSE);
}

代码示例来源:origin: chengdedeng/waf

/***************************************************************************
 * Reading
 **************************************************************************/
@Override
protected ConnectionState readHTTPInitial(HttpRequest httpRequest) {
  LOG.debug("Received raw request: {}", httpRequest);
  // if we cannot parse the request, immediately return a 400 and close the connection, since we do not know what state
  // the client thinks the connection is in
  if (httpRequest.getDecoderResult().isFailure()) {
    LOG.debug("Could not parse request from client. Decoder result: {}", httpRequest.getDecoderResult().toString());
    FullHttpResponse response = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1,
        HttpResponseStatus.BAD_REQUEST,
        "Unable to parse HTTP request");
    HttpHeaders.setKeepAlive(response, false);
    respondWithShortCircuitResponse(response);
    return DISCONNECT_REQUESTED;
  }
  boolean authenticationRequired = authenticationRequired(httpRequest);
  if (authenticationRequired) {
    LOG.debug("Not authenticated!!");
    return AWAITING_PROXY_AUTHENTICATION;
  } else {
    return doReadHTTPInitial(httpRequest);
  }
}

代码示例来源:origin: linsongze/nettyholdspringmvc

@Override
public void messageReceived(ChannelHandlerContext ctx, HttpRequest request) throws Exception {
  if (!request.getDecoderResult().isSuccess()) {
    sendError(ctx, BAD_REQUEST);
    return;
  }
  MockHttpServletRequest servletRequest = createServletRequest(request);
  MockHttpServletResponse servletResponse = new MockHttpServletResponse();
  this.servlet.service(servletRequest, servletResponse);
  HttpResponseStatus status = HttpResponseStatus.valueOf(servletResponse.getStatus());
  HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status);
  for (String name : servletResponse.getHeaderNames()) {
    for (Object value : servletResponse.getHeaderValues(name)) {
      response.addHeader(name, value);
    }
  }
  // Write the initial line and the header.
  ctx.write(response);
  InputStream contentStream = new ByteArrayInputStream(servletResponse.getContentAsByteArray());
  // Write the content.
  ChannelFuture writeFuture = ctx.write(new ChunkedStream(contentStream));
  writeFuture.addListener(ChannelFutureListener.CLOSE);
}

代码示例来源:origin: com.github.mike10004/littleproxy

/***************************************************************************
 * Reading
 **************************************************************************/
@Override
protected ConnectionState readHTTPInitial(HttpRequest httpRequest) {
  LOG.debug("Received raw request: {}", httpRequest);
  // if we cannot parse the request, immediately return a 400 and close the connection, since we do not know what state
  // the client thinks the connection is in
  if (httpRequest.getDecoderResult().isFailure()) {
    LOG.debug("Could not parse request from client. Decoder result: {}", httpRequest.getDecoderResult().toString());
    FullHttpResponse response = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1,
        HttpResponseStatus.BAD_REQUEST,
        "Unable to parse HTTP request");
    HttpHeaders.setKeepAlive(response, false);
    respondWithShortCircuitResponse(response);
    return DISCONNECT_REQUESTED;
  }
  boolean authenticationRequired = authenticationRequired(httpRequest);
  if (authenticationRequired) {
    LOG.debug("Not authenticated!!");
    return AWAITING_PROXY_AUTHENTICATION;
  } else {
    return doReadHTTPInitial(httpRequest);
  }
}

代码示例来源:origin: buremba/netty-rest

if (((HttpRequest) msg).getDecoderResult().isFailure()) {
  Throwable cause = ((HttpRequest) msg).getDecoderResult().cause();
  if (request == null) {
    request = createRequest(ctx);

相关文章