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

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

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

HttpRequest.setHeaders介绍

暂无

代码示例

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

/**
 * When a {@link HttpCacheEntry} does not exist for a specific
 * {@link org.apache.hc.core5.http.HttpRequest} we attempt to see if an existing
 * {@link HttpCacheEntry} is appropriate by building a conditional
 * {@link org.apache.hc.core5.http.HttpRequest} using the variants' ETag values.
 * If no such values exist, the request is unmodified
 *
 * @param request the original request from the caller
 * @param variants
 * @return the wrapped request
 */
public T buildConditionalRequestFromVariants(final T request, final Map<String, Variant> variants) {
  final T newRequest = messageCopier.copy(request);
  newRequest.setHeaders(request.getHeaders());
  // we do not support partial content so all etags are used
  final StringBuilder etags = new StringBuilder();
  boolean first = true;
  for(final String etag : variants.keySet()) {
    if (!first) {
      etags.append(",");
    }
    first = false;
    etags.append(etag);
  }
  newRequest.setHeader(HeaderConstants.IF_NONE_MATCH, etags.toString());
  return newRequest;
}

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

newRequest.setHeaders(request.getHeaders());
final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG);
if (eTag != null) {

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

/**
 * When a {@link HttpCacheEntry} does not exist for a specific
 * {@link org.apache.hc.core5.http.HttpRequest} we attempt to see if an existing
 * {@link HttpCacheEntry} is appropriate by building a conditional
 * {@link org.apache.hc.core5.http.HttpRequest} using the variants' ETag values.
 * If no such values exist, the request is unmodified
 *
 * @param request the original request from the caller
 * @param variants
 * @return the wrapped request
 */
public T buildConditionalRequestFromVariants(final T request, final Map<String, Variant> variants) {
  final T newRequest = messageCopier.copy(request);
  newRequest.setHeaders(request.getHeaders());
  // we do not support partial content so all etags are used
  final StringBuilder etags = new StringBuilder();
  boolean first = true;
  for(final String etag : variants.keySet()) {
    if (!first) {
      etags.append(",");
    }
    first = false;
    etags.append(etag);
  }
  newRequest.setHeader(HeaderConstants.IF_NONE_MATCH, etags.toString());
  return newRequest;
}

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

request.setHeaders();
for (final Iterator<Header> it = original.headerIterator(); it.hasNext(); ) {
  request.addHeader(it.next());

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

newRequest.setHeaders(request.getHeaders());
final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG);
if (eTag != null) {

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

if (!StandardMethods.isSafe(request.getMethod())) {
  final HttpRequest httpGet = new BasicHttpRequest(StandardMethods.GET.name(), redirectUri);
  httpGet.setHeaders(scope.originalRequest.getHeaders());
  state.currentRequest = httpGet;
  state.currentEntityProducer = null;

相关文章