org.apache.hc.core5.http.Header.getName()方法的使用及代码示例

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

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

Header.getName介绍

暂无

代码示例

代码示例来源:origin: structurizr/java

private void debugRequest(HttpUriRequestBase httpRequest, String content) {
  if (log.isDebugEnabled()) {
    log.debug(httpRequest.getMethod() + " " + httpRequest.getPath());
    Header[] headers = httpRequest.getHeaders();
    for (Header header : headers) {
      log.debug(header.getName() + ": " + header.getValue());
    }
    if (content != null) {
      log.debug(content);
    }
  }
}

代码示例来源:origin: apache/httpcomponents-client

/**
 * Returns all the headers that were on the origin response.
 */
@Override
public Header[] getHeaders() {
  final HeaderGroup filteredHeaders = new HeaderGroup();
  for (final Iterator<Header> iterator = responseHeaders.headerIterator(); iterator.hasNext();) {
    final Header header = iterator.next();
    if (!REQUEST_METHOD_HEADER_NAME.equals(header.getName())) {
      filteredHeaders.addHeader(header);
    }
  }
  return filteredHeaders.getHeaders();
}

代码示例来源:origin: apache/httpcomponents-client

final Header responseHeader = it.next();
if (HttpHeaders.CONTENT_ENCODING.equals(responseHeader.getName())) {
  continue;
headerGroup.removeHeaders(responseHeader.getName());
if (HeaderConstants.WARNING.equalsIgnoreCase(cacheHeader.getName())) {
  final String warningValue = cacheHeader.getValue();
  if (warningValue != null && warningValue.startsWith("1")) {
final Header responseHeader = it.next();
if (HttpHeaders.CONTENT_ENCODING.equals(responseHeader.getName())) {
  continue;

代码示例来源:origin: apache/httpcomponents-client

public static boolean isEndToEndHeaderSubset(final HttpMessage r1, final HttpMessage r2) {
  for (final Header h : r1.getHeaders()) {
    if (!isHopByHopHeader(h.getName())) {
      final String r1val = getCanonicalHeaderValue(r1, h.getName());
      final String r2val = getCanonicalHeaderValue(r2, h.getName());
      if (!r1val.equals(r2val)) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: apache/httpcomponents-client

private void headersNotContain(final Header[] headers, final String name, final String value) {
    for (final Header header : headers) {
      if (header.getName().equals(name)) {
        if (header.getValue().equals(value)) {
          fail("Header [" + name + ": " + value + "] found in headers where it should not be");
        }
      }
    }
  }
}

代码示例来源:origin: apache/httpcomponents-client

private void headersContain(final Header[] headers, final String name, final String value) {
  for (final Header header : headers) {
    if (header.getName().equals(name)) {
      if (header.getValue().equals(value)) {
        return;
      }
    }
  }
  fail("Header [" + name + ": " + value + "] not found in headers.");
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public boolean matches(final Object item) {
  if (item instanceof MessageHeaders) {
    final MessageHeaders messageHeaders = (MessageHeaders) item;
    for (final Iterator<Header> it = messageHeaders.headerIterator(); it.hasNext(); ) {
      final Header header = it.next();
      if (headerName.equalsIgnoreCase(header.getName()) && LangUtils.equals(headerValue, header.getValue())) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

/**
 * Checks whether a header is part of the iteration.
 *
 * @param index     the index of the header to check
 *
 * @return  {@code true} if the header should be part of the
 *          iteration, {@code false} to skip
 */
private boolean filterHeader(final int index) {
  return (this.headerName == null) ||
    this.headerName.equalsIgnoreCase(this.allHeaders[index].getName());
}

代码示例来源:origin: apache/httpcomponents-core

/**
 * Checks whether a header is part of the iteration.
 *
 * @param index     the index of the header to check
 *
 * @return  {@code true} if the header should be part of the
 *          iteration, {@code false} to skip
 */
private boolean filterHeader(final int index) {
  return (this.headerName == null) ||
    this.headerName.equalsIgnoreCase(this.allHeaders[index].getName());
}

代码示例来源:origin: apache/httpcomponents-core

@Override
public Set<String> getTrailerNames() {
  final Set<String> names = new LinkedHashSet<>();
  for (final Header trailer: trailers) {
    names.add(trailer.getName());
  }
  return names;
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

@Override
public Set<String> getTrailerNames() {
  final Set<String> names = new LinkedHashSet<>();
  for (final Header trailer: trailers) {
    names.add(trailer.getName());
  }
  return names;
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

public AsyncRequestBuilder removeHeaders(final String name) {
  if (name == null || headergroup == null) {
    return this;
  }
  for (final Iterator<Header> i = headergroup.headerIterator(); i.hasNext(); ) {
    final Header header = i.next();
    if (name.equalsIgnoreCase(header.getName())) {
      i.remove();
    }
  }
  return this;
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

public RequestBuilder removeHeaders(final String name) {
  if (name == null || headerGroup == null) {
    return this;
  }
  for (final Iterator<Header> i = headerGroup.headerIterator(); i.hasNext(); ) {
    final Header header = i.next();
    if (name.equalsIgnoreCase(header.getName())) {
      i.remove();
    }
  }
  return this;
}

代码示例来源:origin: apache/httpcomponents-client

final Header h1 = expectedHeaders[i];
final Header h2 = otherHeaders[i];
if (!h1.getName().equals(h2.getName()) || !LangUtils.equals(h1.getValue(), h2.getValue())) {
  return false;

代码示例来源:origin: apache/httpcomponents-client

@Test
public void testBuildConditionalRequestWithETag() {
  final String theMethod = "GET";
  final String theUri = "/theuri";
  final String theETag = "this is my eTag";
  final HttpRequest basicRequest = new BasicHttpRequest(theMethod, theUri);
  basicRequest.addHeader("Accept-Encoding", "gzip");
  final HttpRequest requestWrapper = RequestCopier.INSTANCE.copy(basicRequest);
  final Header[] headers = new Header[] {
      new BasicHeader("Date", DateUtils.formatDate(new Date())),
      new BasicHeader("Last-Modified", DateUtils.formatDate(new Date())),
      new BasicHeader("ETag", theETag) };
  final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry(headers);
  final HttpRequest newRequest = impl.buildConditionalRequest(requestWrapper, cacheEntry);
  Assert.assertNotSame(basicRequest, newRequest);
  Assert.assertEquals(theMethod, newRequest.getMethod());
  Assert.assertEquals(theUri, newRequest.getRequestUri());
  Assert.assertEquals(3, newRequest.getHeaders().length);
  Assert.assertEquals("Accept-Encoding", newRequest.getHeaders()[0].getName());
  Assert.assertEquals("gzip", newRequest.getHeaders()[0].getValue());
  Assert.assertEquals("If-None-Match", newRequest.getHeaders()[1].getName());
  Assert.assertEquals(theETag, newRequest.getHeaders()[1].getValue());
}

代码示例来源:origin: apache/httpcomponents-client

@Test
public void testBuildConditionalRequestWithLastModified() {
  final String theMethod = "GET";
  final String theUri = "/theuri";
  final String lastModified = "this is my last modified date";
  final HttpRequest basicRequest = new BasicHttpRequest(theMethod, theUri);
  basicRequest.addHeader("Accept-Encoding", "gzip");
  final HttpRequest requestWrapper = RequestCopier.INSTANCE.copy(basicRequest);
  final Header[] headers = new Header[] {
      new BasicHeader("Date", DateUtils.formatDate(new Date())),
      new BasicHeader("Last-Modified", lastModified) };
  final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry(headers);
  final HttpRequest newRequest = impl.buildConditionalRequest(requestWrapper, cacheEntry);
  Assert.assertNotSame(basicRequest, newRequest);
  Assert.assertEquals(theMethod, newRequest.getMethod());
  Assert.assertEquals(theUri, newRequest.getRequestUri());
  Assert.assertEquals(2, newRequest.getHeaders().length);
  Assert.assertEquals("Accept-Encoding", newRequest.getHeaders()[0].getName());
  Assert.assertEquals("gzip", newRequest.getHeaders()[0].getValue());
  Assert.assertEquals("If-Modified-Since", newRequest.getHeaders()[1].getName());
  Assert.assertEquals(lastModified, newRequest.getHeaders()[1].getValue());
}

代码示例来源:origin: apache/httpcomponents-core

public void encodeHeader(
    final ByteArrayBuffer dst, final Header header) throws CharacterCodingException {
  Args.notNull(dst, "ByteArrayBuffer");
  Args.notNull(header, "Header");
  encodeHeader(dst, header.getName(), header.getValue(), header.isSensitive());
}

代码示例来源:origin: apache/httpcomponents-core

@Test
public void testConstructor() {
  final Header param = new BasicHeader("name", "value");
  Assert.assertEquals("name", param.getName());
  Assert.assertEquals("value", param.getValue());
}

代码示例来源:origin: apache/httpcomponents-core

@Test
public void testBasicConstructorNullValue() {
  final Header header = new BasicHeader("name", null);
  Assert.assertEquals("name", header.getName());
  Assert.assertEquals(null, header.getValue());
}

代码示例来源:origin: apache/httpcomponents-core

@Test
public void testBasicConstructor() {
  final Header header = new BasicHeader("name", "value");
  Assert.assertEquals("name", header.getName());
  Assert.assertEquals("value", header.getValue());
}

相关文章