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

x33g5p2x  于2022-01-19 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(168)

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

HttpRequest.removeHeaders介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

private static class ContentLengthHeaderRemover implements HttpRequestInterceptor{
  @Override
  public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    request.removeHeaders(HTTP.CONTENT_LEN);// fighting org.apache.http.protocol.RequestContent's ProtocolException("Content-Length header already present");
  }
}
...
  HttpClientBuilder httpClientBuilder = HttpClients.custom();
  httpClientBuilder.addInterceptorFirst(new CcontentLengthHeaderRemover());

代码示例来源:origin: OfficeDev/ews-java-api

@Override
public Map<String, Header> getChallenges(HttpHost authhost, HttpResponse response, HttpContext context)
  throws MalformedChallengeException {
 try {
  // Get the request from the context
  HttpClientContext clientContext = HttpClientContext.adapt(context);
  HttpRequest request = clientContext.getRequest();
  // Save new cookies in the context
  responseProcessCookies.process(response, context);
  // Remove existing cookies and set the new cookies in the request
  request.removeHeaders("Cookie");
  requestAddCookies.process(request, context);
 } catch (HttpException e) {
  throw new RuntimeException(e); // Looking at the source of responseProcessCookies this never happens
 } catch (IOException e) {
  throw new RuntimeException(e); // Looking at the source of responseProcessCookies this never happens
 }
 return super.getChallenges(authhost, response, context);
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
  public void process(final HttpRequest request, final HttpContext context) {
    request.removeHeaders(SDSSession.SDS_AUTH_TOKEN_HEADER);
  }
});

代码示例来源:origin: com.microsoft.azure/azure-core

@Override
  public void removeHeader(final String name) {
    clientRequest.removeHeaders(name);
  }
}

代码示例来源:origin: com.opentable.components/otj-jaxrs-clientfactory-resteasy

@Override
  public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    for (String header : headers) {
      request.removeHeaders(header);
    }
  }
}

代码示例来源:origin: com.microsoft.azure/azure-core

@Override
  public void process(HttpRequest request, HttpContext context) {
    request.removeHeaders("Content-Length");
  }
}

代码示例来源:origin: com.microsoft.windowsazure/microsoft-azure-api-core

@Override
  public void removeHeader(final String name) {
    clientRequest.removeHeaders(name);
  }
}

代码示例来源:origin: org.apache.axis2/axis2-transport-http

public void removeHeaders(final String name) {
  this.request.removeHeaders(name);
}

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

@Override
public void removeHeaders(String name)
{
  implementation.removeHeaders(name);
}

代码示例来源:origin: apache/axis2-java

public void removeHeaders(final String name) {
  this.request.removeHeaders(name);
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
  public void process(final HttpRequest request, final HttpContext context) {
    if(StringUtils.isNotBlank(token)) {
      request.removeHeaders(SDSSession.SDS_AUTH_TOKEN_HEADER);
      request.addHeader(SDSSession.SDS_AUTH_TOKEN_HEADER, token);
    }
  }
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

@Override
  public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    if (request instanceof HttpEntityEnclosingRequest) {
      if (request.containsHeader(HTTP.TRANSFER_ENCODING)) {
        request.removeHeaders(HTTP.TRANSFER_ENCODING);
      }
      if (request.containsHeader(HTTP.CONTENT_LEN)) {
        request.removeHeaders(HTTP.CONTENT_LEN);
      }
    }
  }
}

代码示例来源:origin: simplegeo/java-simplegeo

@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
  if (context.getAttribute("AuthHeader") != null) {
    request.removeHeaders("Authorization");
    request.addHeader((Header) context.getAttribute("AuthHeader"));
  }
}

代码示例来源:origin: spring-projects/spring-ws

@Override
  public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    if (request instanceof HttpEntityEnclosingRequest) {
      if (request.containsHeader(HTTP.TRANSFER_ENCODING)) {
        request.removeHeaders(HTTP.TRANSFER_ENCODING);
      }
      if (request.containsHeader(HTTP.CONTENT_LEN)) {
        request.removeHeaders(HTTP.CONTENT_LEN);
      }
    }
  }
}

代码示例来源:origin: com.machinepublishers/jbrowserdriver

@Override
 protected HttpResponse doSendRequest(HttpRequest request, HttpClientConnection conn, HttpContext context) throws IOException, HttpException {
  request.removeHeaders("Via");
  return super.doSendRequest(request, conn, context);
 }
})

代码示例来源:origin: zalando/riptide

void updateHeaders(final HttpRequest request, final HttpEntity entity) {
  request.removeHeaders(HTTP.CONTENT_LEN);
  request.removeHeaders(HTTP.CONTENT_ENCODING);
  request.addHeader(entity.getContentEncoding());
  request.removeHeaders(HTTP.TRANSFER_ENCODING);
  request.setHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
  public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    if (request instanceof HttpEntityEnclosingRequest) {
      if (request.containsHeader(HTTP.TRANSFER_ENCODING)) {
        request.removeHeaders(HTTP.TRANSFER_ENCODING);
      }
      if (request.containsHeader(HTTP.CONTENT_LEN)) {
        request.removeHeaders(HTTP.CONTENT_LEN);
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

httpClient.addRequestInterceptor(new HttpRequestInterceptor() {
   @Override
   public void process(HttpRequest request, HttpContext context)
       throws HttpException, IOException {
     LOG.info("***************** Entered My Interceptor ****************************");
     Header[] headers = request.getAllHeaders();
     for (Header eachHeader : headers) {
       LOG.info("Headers -- Name: {}, Value: {} ",
           eachHeader.getName(), eachHeader.getValue());
     }
     request.removeHeaders("Cookie");
   }
 });

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

private void decrementOPTIONSMaxForwardsIfGreaterThen0(final HttpRequest request) {
  if (!HeaderConstants.OPTIONS_METHOD.equals(request.getRequestLine().getMethod())) {
    return;
  }
  final Header maxForwards = request.getFirstHeader(HeaderConstants.MAX_FORWARDS);
  if (maxForwards == null) {
    return;
  }
  request.removeHeaders(HeaderConstants.MAX_FORWARDS);
  final int currentMaxForwards = Integer.parseInt(maxForwards.getValue());
  request.setHeader(HeaderConstants.MAX_FORWARDS, Integer.toString(currentMaxForwards - 1));
}

代码示例来源:origin: org.apache.httpcomponents/com.springsource.org.apache.httpcomponents.httpclient-cache

private void decrementOPTIONSMaxForwardsIfGreaterThen0(HttpRequest request) {
  if (!HeaderConstants.OPTIONS_METHOD.equals(request.getRequestLine().getMethod())) {
    return;
  }
  Header maxForwards = request.getFirstHeader(HeaderConstants.MAX_FORWARDS);
  if (maxForwards == null) {
    return;
  }
  request.removeHeaders(HeaderConstants.MAX_FORWARDS);
  int currentMaxForwards = Integer.parseInt(maxForwards.getValue());
  request.setHeader(HeaderConstants.MAX_FORWARDS, Integer.toString(currentMaxForwards - 1));
}

相关文章