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

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

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

HttpRequest.method介绍

[英]Returns the HttpMethod of this HttpRequest.
[中]返回此HttpRequest的HttpMethod。

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public HttpMethod method() {
 return request.method();
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public HttpMethod getMethod() {
 return request.method();
}

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

@Override
public HttpMethod getMethod() {
  return ((HttpRequest) message).method();
}

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

@Override
public HttpMethod getMethod() {
  return request.method();
}

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

@Override
public HttpMethod method() {
  return request.method();
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public HttpMethod method() {
  return request.method();
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
@Deprecated
public HttpMethod getMethod() {
  return request.method();
}

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

@Override
  protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
    int oldSize = out.size();
    super.decode(ctx, buffer, out);
    int size = out.size();
    for (int i = oldSize; i < size; i++) {
      Object obj = out.get(i);
      if (obj instanceof HttpRequest) {
        queue.add(((HttpRequest) obj).method());
      }
    }
  }
}

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

private static void appendInitialLine(StringBuilder buf, HttpRequest req) {
  buf.append(req.method());
  buf.append(' ');
  buf.append(req.uri());
  buf.append(' ');
  buf.append(req.protocolVersion());
  buf.append(StringUtil.NEWLINE);
}

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

@Override
protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List<Object> out)
    throws Exception {
  CharSequence acceptedEncoding = msg.headers().get(HttpHeaderNames.ACCEPT_ENCODING);
  if (acceptedEncoding == null) {
    acceptedEncoding = HttpContentDecoder.IDENTITY;
  }
  HttpMethod meth = msg.method();
  if (meth == HttpMethod.HEAD) {
    acceptedEncoding = ZERO_LENGTH_HEAD;
  } else if (meth == HttpMethod.CONNECT) {
    acceptedEncoding = ZERO_LENGTH_CONNECT;
  }
  acceptEncodingQueue.add(acceptedEncoding);
  out.add(ReferenceCountUtil.retain(msg));
}

代码示例来源:origin: Netflix/zuul

@Override
  public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
  {
    if (evt instanceof HttpLifecycleChannelHandler.CompleteEvent)
    {
      // Get the stored request, and remove the attr from channel to cleanup.
      RequestState state = ctx.channel().attr(ATTR_REQ_STATE).get();
      ctx.channel().attr(ATTR_REQ_STATE).set(null);
      // Response complete, so now write to access log.
      long durationNs = System.nanoTime() - state.startTimeNs;
      String remoteIp = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SOURCE_ADDRESS).get();
      Integer localPort = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).get();
      if (state.response == null) {
        LOG.debug("Response null in AccessLog, Complete reason={}, duration={}, url={}, method={}",
            ((HttpLifecycleChannelHandler.CompleteEvent)evt).getReason(),
            durationNs/(1000*1000), state.request != null ? state.request.uri() : "-",
            state.request != null ? state.request.method() : "-");
      }
      publisher.log(ctx.channel(), state.request, state.response, state.dateTime, localPort, remoteIp, durationNs,
          state.requestBodySize, state.responseBodySize);
    }
    super.userEventTriggered(ctx, evt);
  }
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
  protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List<Object> out) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Server {}:{} Received Request: {} {}", embeddedServer.getHost(), embeddedServer.getPort(), msg.method(), msg.uri());
    }
    out.add(new NettyHttpRequest<>(msg, ctx, conversionService, configuration));
  }
}

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

private static boolean isPreflightRequest(final HttpRequest request) {
  final HttpHeaders headers = request.headers();
  return request.method().equals(OPTIONS) &&
      headers.contains(HttpHeaderNames.ORIGIN) &&
      headers.contains(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD);
}

代码示例来源:origin: oracle/helidon

@Override
public Http.RequestMethod method() {
  return Http.RequestMethod.create(nettyRequest.method().name());
}

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * @param nettyRequest      The Http netty request
 * @param conversionService The conversion service
 */
public AbstractNettyHttpRequest(io.netty.handler.codec.http.HttpRequest nettyRequest, ConversionService conversionService) {
  this.nettyRequest = nettyRequest;
  this.conversionService = conversionService;
  String fullUri = nettyRequest.uri();
  this.uri = URI.create(fullUri);
  this.httpMethod = HttpMethod.valueOf(nettyRequest.method().name());
}

代码示例来源:origin: AsyncHttpClient/async-http-client

private boolean isConnectAlreadyDone(Request request, NettyResponseFuture<?> future) {
 return future != null
     && future.getNettyRequest() != null
     && future.getNettyRequest().getHttpRequest().method() == HttpMethod.CONNECT
     && !request.getMethod().equals(CONNECT);
}

代码示例来源:origin: blynkkk/blynk-server

private HandlerHolder lookupHandler(HttpRequest req) {
  for (HandlerWrapper handler : handlers) {
    if (handler.httpMethod == req.method()) {
      Matcher matcher = handler.uriTemplate.matcher(req.uri());
      if (matcher.matches()) {
        Map<String, String> extractedParams = handler.uriTemplate.extractParameters(matcher);
        return new HandlerHolder(handler, extractedParams);
      }
    }
  }
  return null;
}

代码示例来源:origin: AsyncHttpClient/async-http-client

private void writeRequest(Channel channel) {
 if (futureIsAlreadyCancelled(channel)) {
  return;
 }
 if (LOGGER.isDebugEnabled()) {
  HttpRequest httpRequest = future.getNettyRequest().getHttpRequest();
  LOGGER.debug("Using new Channel '{}' for '{}' to '{}'", channel, httpRequest.method(), httpRequest.uri());
 }
 Channels.setAttribute(channel, future);
 channelManager.registerOpenChannel(channel);
 future.attachChannel(channel, false);
 requestSender.writeRequest(future, channel);
}

代码示例来源:origin: blynkkk/blynk-server

private void invokeHandler(ChannelHandlerContext ctx, HttpRequest req,
              HandlerWrapper handler, Map<String, String> extractedParams) {
  log.debug("{} : {}", req.method().name(), req.uri());
  try (URIDecoder uriDecoder = new URIDecoder(req, extractedParams)) {
    Object[] params = handler.fetchParams(ctx, uriDecoder);
    finishHttp(ctx, uriDecoder, handler, params);
  }
}

代码示例来源:origin: Netflix/zuul

@Override
  public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
  {
    if (evt instanceof HttpLifecycleChannelHandler.CompleteEvent)
    {
      // Get the stored request, and remove the attr from channel to cleanup.
      RequestState state = ctx.channel().attr(ATTR_REQ_STATE).get();
      ctx.channel().attr(ATTR_REQ_STATE).set(null);
      // Response complete, so now write to access log.
      long durationNs = System.nanoTime() - state.startTimeNs;
      String remoteIp = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SOURCE_ADDRESS).get();
      Integer localPort = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SERVER_LOCAL_PORT).get();
      if (state.response == null) {
        LOG.debug("Response null in AccessLog, Complete reason={}, duration={}, url={}, method={}",
            ((HttpLifecycleChannelHandler.CompleteEvent)evt).getReason(),
            durationNs/(1000*1000), state.request != null ? state.request.uri() : "-",
            state.request != null ? state.request.method() : "-");
      }
      publisher.log(ctx.channel(), state.request, state.response, state.dateTime, localPort, remoteIp, durationNs,
          state.requestBodySize, state.responseBodySize);
    }
    super.userEventTriggered(ctx, evt);
  }
}

相关文章