org.eclipse.jetty.server.Request.getHeaderNames()方法的使用及代码示例

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

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

Request.getHeaderNames介绍

暂无

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory headers(boolean lowerKeys) {
  Enumeration<String> headerNames = request.getHeaderNames();
  ArrayMemory result = ArrayMemory.createHashed(15);
  while (headerNames.hasMoreElements()) {
    String key = headerNames.nextElement();
    if (lowerKeys) {
      key = key.toLowerCase();
    }
    ArrayMemory value = ArrayMemory.ofStringEnumeration(request.getHeaders(key));
    if (value.size() == 0) {
      result.putAsKeyString(key, Memory.NULL);
    } else if (value.size() == 1) {
      result.putAsKeyString(key, value.shift());
    } else {
      result.putAsKeyString(key, value);
    }
  }
  return result.toConstant();
}

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

new MapPropertiesDelegate());
requestContext.setEntityStream(request.getInputStream());
final Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
  final String headerName = headerNames.nextElement();

代码示例来源:origin: OAuth-Apis/apis

private String getHeaderCaseInsensitive(Request request, String headerName) {
  Enumeration<String> headerNames = (Enumeration<String>) request.getHeaderNames();
  while (headerNames.hasMoreElements()){
    String curHeaderName = (String) headerNames.nextElement();
    if (curHeaderName.toLowerCase().equals(headerName)) {
      return request.getHeader(curHeaderName);
    }
  }
  return null;
}

代码示例来源:origin: com.madgag/org.eclipse.jgit.junit.http

private static Map<String, String> cloneHeaders(final Request req) {
  Map<String, String> r = new TreeMap<String, String>();
  Enumeration hn = req.getHeaderNames();
  while (hn.hasMoreElements()) {
    String key = (String) hn.nextElement();
    if (!r.containsKey(key)) {
      r.put(key, req.getHeader(key));
    }
  }
  return Collections.unmodifiableMap(r);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit.junit.http

private static Map<String, String> cloneHeaders(Request req) {
  Map<String, String> r = new TreeMap<>();
  Enumeration hn = req.getHeaderNames();
  while (hn.hasMoreElements()) {
    String key = (String) hn.nextElement();
    if (!r.containsKey(key)) {
      r.put(key, req.getHeader(key));
    }
  }
  return Collections.unmodifiableMap(r);
}

代码示例来源:origin: org.apache.maven.wagon/wagon-provider-test

public void handle( String target, Request baseRrequest, HttpServletRequest request,
  HttpServletResponse response ) throws IOException, ServletException
{
  headers = new HashMap<String, String>();
  for ( Enumeration<String> e = baseRrequest.getHeaderNames(); e.hasMoreElements(); )
  {
    String name = e.nextElement();
    Enumeration headerValues = baseRrequest.getHeaders( name );
    // as per HTTP spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
    // multiple values for the same header key are concatenated separated by comma
    // otherwise we wouldn't notice headers with same key added multiple times
    StringBuffer combinedHeaderValue = new StringBuffer();
    for ( int i = 0; headerValues.hasMoreElements(); i++ )
    {
      if ( i > 0 )
      {
        combinedHeaderValue.append( "," );
      }
      combinedHeaderValue.append( headerValues.nextElement() );
    }
    headers.put( name, combinedHeaderValue.toString() );
  }
  response.setContentType( "text/plain" );
  response.setStatus( HttpServletResponse.SC_OK );
  response.getWriter().print( "Hello, World!" );
  handlerRequestResponses.add(
    new HandlerRequestResponse( baseRrequest.getMethod(), ( (Response) response ).getStatus(),
                  baseRrequest.getRequestURI() ) );
  baseRrequest.setHandled( true );
}

代码示例来源:origin: apache/maven-wagon

public void handle( String target, Request baseRrequest, HttpServletRequest request,
  HttpServletResponse response ) throws IOException, ServletException
{
  headers = new HashMap<String, String>();
  for ( Enumeration<String> e = baseRrequest.getHeaderNames(); e.hasMoreElements(); )
  {
    String name = e.nextElement();
    Enumeration headerValues = baseRrequest.getHeaders( name );
    // as per HTTP spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
    // multiple values for the same header key are concatenated separated by comma
    // otherwise we wouldn't notice headers with same key added multiple times
    StringBuffer combinedHeaderValue = new StringBuffer();
    for ( int i = 0; headerValues.hasMoreElements(); i++ )
    {
      if ( i > 0 )
      {
        combinedHeaderValue.append( "," );
      }
      combinedHeaderValue.append( headerValues.nextElement() );
    }
    headers.put( name, combinedHeaderValue.toString() );
  }
  response.setContentType( "text/plain" );
  response.setStatus( HttpServletResponse.SC_OK );
  response.getWriter().print( "Hello, World!" );
  handlerRequestResponses.add(
    new HandlerRequestResponse( baseRrequest.getMethod(), ( (Response) response ).getStatus(),
                  baseRrequest.getRequestURI() ) );
  baseRrequest.setHandled( true );
}

代码示例来源:origin: org.opendaylight.iotdm/onem2msimpleadapter-impl

@Override
  public void handle(String target, Request baseRequest,
            HttpServletRequest httpRequest,
            HttpServletResponse httpResponse) throws IOException, ServletException {
    response = null;
    httpRSC = HttpServletResponse.SC_OK;
    String method = baseRequest.getMethod().toLowerCase();
    String uri = baseRequest.getRequestURI();
    String payload = IOUtils.toString(baseRequest.getInputStream()).trim();
    LOG.info("handle: received http message: start");
    LOG.info("Method {}", method);
    LOG.info("URI {}", uri);
    LOG.info("RemoteAddr {}", baseRequest.getRemoteAddr());
    for (Enumeration<String> e = baseRequest.getHeaderNames(); e.hasMoreElements(); ) {
      String header = e.nextElement();
      LOG.info("Header: {}, Value: {}", header, baseRequest.getHeader(header));
    }
    LOG.info("payload: {}", payload);
    if (method.compareToIgnoreCase("POST") == 0 || method.compareToIgnoreCase("PUT") == 0) {
      processHttpMessage(baseRequest, uri, payload);
    }
    sendHttpResponse(httpResponse);
    baseRequest.setHandled(true);
    LOG.info("handle: received http message: end");
  }
}

代码示例来源:origin: com.nesscomputing.components/ness-tracking

for (Enumeration<String> e = request.getHeaderNames(); e.hasMoreElements(); ) {
  String headerName = e.nextElement();
  List<HttpClientHeader> headers = reqHeaders.get(headerName);

相关文章

Request类方法