org.glassfish.grizzly.http.server.Request.getHeaderNames()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(192)

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

Request.getHeaderNames介绍

[英]Return the names of all headers received with this request.
[中]返回与此请求一起接收的所有标头的名称。

代码示例

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

@Override
public void service(final Request request, final Response response) {
  final ResponseWriter responseWriter = new ResponseWriter(response, configSetStatusOverSendError);
  try {
    logger.debugLog("GrizzlyHttpContainer.service(...) started");
    URI baseUri = getBaseUri(request);
    URI requestUri = getRequestUri(request);
    final ContainerRequest requestContext = new ContainerRequest(baseUri,
        requestUri, request.getMethod().getMethodString(),
        getSecurityContext(request), new GrizzlyRequestPropertiesDelegate(request));
    requestContext.setEntityStream(request.getInputStream());
    for (final String headerName : request.getHeaderNames()) {
      requestContext.headers(headerName, request.getHeaders(headerName));
    }
    requestContext.setWriter(responseWriter);
    requestContext.setRequestScopedInitializer(injectionManager -> {
      injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request);
      injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response);
    });
    appHandler.handle(requestContext);
  } finally {
    logger.debugLog("GrizzlyHttpContainer.service(...) finished");
  }
}

代码示例来源:origin: javaee/grizzly

@Override
  public Enumeration<String> run() {
    return new Enumerator<>(request.getHeaderNames());
  }           
}

代码示例来源:origin: javaee/grizzly

@Override
  public Enumeration<String> run() {
    return new Enumerator<>(request.getHeaderNames());
  }           
}

代码示例来源:origin: javaee/grizzly

@Override
  public Enumeration<String> run() {
    return new Enumerator<>(request.getHeaderNames());
  }           
}

代码示例来源:origin: javaee/grizzly

@Override
  public Enumeration<String> run() {
    return new Enumerator<>(request.getHeaderNames());
  }           
}

代码示例来源:origin: org.glassfish.main.web/web-core

/**
 * Return the names of all headers received with this request.
 */
@Override
public Enumeration<String> getHeaderNames() {
  return new Enumerator<String>(coyoteRequest.getHeaderNames().iterator());
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

@Override
  public Enumeration<String> run() {
    return new Enumerator<>(request.getHeaderNames());
  }           
}

代码示例来源:origin: javaee/grizzly

@Override
  public Enumeration<String> run() {
    return new Enumerator<>(request.getHeaderNames());
  }           
}

代码示例来源:origin: miltonio/milton2

@Override
public Map<String, String> getHeaders() {
  if( mapOfHeaders == null ) {
    mapOfHeaders = new HashMap<String, String>();
    for( String headerName : wrapped.getHeaderNames() ) {
      String s = wrapped.getHeader(headerName);
      mapOfHeaders.put(headerName, s);
    }
  }
  return mapOfHeaders;
}

代码示例来源:origin: org.glassfish.main.admin/admin-util

private static Map<String,String> headers(final Request req) {
  final Map<String,String> result = new HashMap<String,String>();
  for (String headerName : req.getHeaderNames()) {
    result.put(headerName(headerName), req.getHeader(headerName));
  }
  return result;
}

代码示例来源:origin: javaee/grizzly

@Override
@Property({MessageContext.HTTP_REQUEST_HEADERS, Packet.INBOUND_TRANSPORT_HEADERS})
public @NotNull Map<String, List<String>> getRequestHeaders() {
  if (requestHeaders == null) {
    requestHeaders = new Headers();
    for (String headerName : request.getHeaderNames()) {
      final List<String> headerValues = new ArrayList<String>(4);
      for (String headerValue : request.getHeaders(headerName)) {
        headerValues.add(headerValue);
      }
      requestHeaders.put(headerName, headerValues);
    }
  }
  
  return requestHeaders;
}

代码示例来源:origin: com.sun.jersey/jersey-grizzly2

private InBoundHeaders getHeaders(final Request request) {
    final InBoundHeaders rh = new InBoundHeaders();
    for (final String name : request.getHeaderNames()) {
      rh.add(name, request.getHeader(name));
    }

    return rh;
  }
}

代码示例来源:origin: jersey/jersey-1.x

private InBoundHeaders getHeaders(final Request request) {
    final InBoundHeaders rh = new InBoundHeaders();
    for (final String name : request.getHeaderNames()) {
      rh.add(name, request.getHeader(name));
    }

    return rh;
  }
}

代码示例来源:origin: javaee/grizzly

public static void writeTraceMessage(final Request request,
    final Response response) throws IOException {
  response.setStatus(HttpStatus.OK_200);
  response.setContentType("message/http");
  final Writer writer = response.getWriter();
  writer.append(request.getMethod().toString()).append(' ')
      .append(request.getRequest().getRequestURIRef().getOriginalRequestURIBC().toString())
      .append(' ').append(request.getProtocol().getProtocolString())
      .append("\r\n");
  for (String headerName : request.getHeaderNames()) {
    for (String headerValue : request.getHeaders(headerName)) {
      writer.append(headerName).append(": ").append(headerValue).append("\r\n");
    }
  }
}

代码示例来源:origin: javaee/grizzly

public static void writeTraceMessage(final Request request,
    final Response response) throws IOException {
  response.setStatus(HttpStatus.OK_200);
  response.setContentType("message/http");
  final Writer writer = response.getWriter();
  writer.append(request.getMethod().toString()).append(' ')
      .append(request.getRequest().getRequestURIRef().getOriginalRequestURIBC().toString())
      .append(' ').append(request.getProtocol().getProtocolString())
      .append("\r\n");
  for (String headerName : request.getHeaderNames()) {
    for (String headerValue : request.getHeaders(headerName)) {
      writer.append(headerName).append(": ").append(headerValue).append("\r\n");
    }
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server

public static void writeTraceMessage(final Request request,
    final Response response) throws IOException {
  response.setStatus(HttpStatus.OK_200);
  response.setContentType("message/http");
  final Writer writer = response.getWriter();
  writer.append(request.getMethod().toString()).append(' ')
      .append(request.getRequest().getRequestURIRef().getOriginalRequestURIBC().toString())
      .append(' ').append(request.getProtocol().getProtocolString())
      .append("\r\n");
  for (String headerName : request.getHeaderNames()) {
    for (String headerValue : request.getHeaders(headerName)) {
      writer.append(headerName).append(": ").append(headerValue).append("\r\n");
    }
  }
}

代码示例来源:origin: javaee/grizzly

public static void writeTraceMessage(final Request request,
    final Response response) throws IOException {
  response.setStatus(HttpStatus.OK_200);
  response.setContentType("message/http");
  final Writer writer = response.getWriter();
  writer.append(request.getMethod().toString()).append(' ')
      .append(request.getRequest().getRequestURIRef().getOriginalRequestURIBC().toString())
      .append(' ').append(request.getProtocol().getProtocolString())
      .append("\r\n");
  for (String headerName : request.getHeaderNames()) {
    for (String headerValue : request.getHeaders(headerName)) {
      writer.append(headerName).append(": ").append(headerValue).append("\r\n");
    }
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

public static void writeTraceMessage(final Request request,
    final Response response) throws IOException {
  response.setStatus(HttpStatus.OK_200);
  response.setContentType("message/http");
  final Writer writer = response.getWriter();
  writer.append(request.getMethod().toString()).append(' ')
      .append(request.getRequest().getRequestURIRef().getOriginalRequestURIBC().toString())
      .append(' ').append(request.getProtocol().getProtocolString())
      .append("\r\n");
  for (String headerName : request.getHeaderNames()) {
    for (String headerValue : request.getHeaders(headerName)) {
      writer.append(headerName).append(": ").append(headerValue).append("\r\n");
    }
  }
}

代码示例来源:origin: javaee/grizzly

public static void writeTraceMessage(final Request request,
    final Response response) throws IOException {
  response.setStatus(HttpStatus.OK_200);
  response.setContentType("message/http");
  final Writer writer = response.getWriter();
  writer.append(request.getMethod().toString()).append(' ')
      .append(request.getRequest().getRequestURIRef().getOriginalRequestURIBC().toString())
      .append(' ').append(request.getProtocol().getProtocolString())
      .append("\r\n");
  for (String headerName : request.getHeaderNames()) {
    for (String headerValue : request.getHeaders(headerName)) {
      writer.append(headerName).append(": ").append(headerValue).append("\r\n");
    }
  }
}

代码示例来源:origin: javaee/grizzly

public static void writeTraceMessage(final Request request,
    final Response response) throws IOException {
  response.setStatus(HttpStatus.OK_200);
  response.setContentType("message/http");
  final Writer writer = response.getWriter();
  writer.append(request.getMethod().toString()).append(' ')
      .append(request.getRequest().getRequestURIRef().getOriginalRequestURIBC().toString())
      .append(' ').append(request.getProtocol().getProtocolString())
      .append("\r\n");
  for (String headerName : request.getHeaderNames()) {
    for (String headerValue : request.getHeaders(headerName)) {
      writer.append(headerName).append(": ").append(headerValue).append("\r\n");
    }
  }
}

相关文章

Request类方法