本文整理了Java中org.apache.http.HttpRequest.removeHeader()
方法的一些代码示例,展示了HttpRequest.removeHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.removeHeader()
方法的具体详情如下:
包路径:org.apache.http.HttpRequest
类名称:HttpRequest
方法名:removeHeader
暂无
代码示例来源:origin: soabase/soabase
@Override
public void removeHeader(Header header)
{
implementation.removeHeader(header);
}
代码示例来源:origin: apache/axis2-java
public void removeHeader(final Header header) {
this.request.removeHeader(header);
}
代码示例来源:origin: org.apache.axis2/axis2-transport-http
public void removeHeader(final Header header) {
this.request.removeHeader(header);
}
代码示例来源:origin: OpenNMS/opennms
@Override
public void process(HttpRequest request, HttpContext ctx) throws HttpException, IOException {
Header host = request.getFirstHeader(HTTP.TARGET_HOST);
if (host != null) {
request.removeHeader(host);
LOG.debug("httpRequestInterceptor: virtual-host is not set, removing host header");
}
}
});
代码示例来源:origin: aliyun/HiTSDB-Client
private void tryCloseConnection(HttpRequest request) {
Header[] headers = request.getHeaders("Connection");
if (headers != null && headers.length > 0) {
for (Header h : headers) {
request.removeHeader(h);
}
}
request.addHeader("Connection", "close");
}
代码示例来源:origin: yiwent/Mobike
@Override
public void process(HttpRequest request, HttpContext context) {
if (!request.containsHeader(HEADER_ACCEPT_ENCODING)) {
request.addHeader(HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
}
for (String header : clientHeaderMap.keySet()) {
if (request.containsHeader(header)) {
Header overwritten = request.getFirstHeader(header);
Log.d(LOG_TAG,
String.format("Headers were overwritten! (%s | %s) overwrites (%s | %s)",
header, clientHeaderMap.get(header),
overwritten.getName(), overwritten.getValue())
);
//remove the overwritten header
request.removeHeader(overwritten);
}
request.addHeader(header, clientHeaderMap.get(header));
}
}
});
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
private void remove100ContinueHeaderIfExists(final HttpRequest request) {
boolean hasHeader = false;
final Header[] expectHeaders = request.getHeaders(HTTP.EXPECT_DIRECTIVE);
List<HeaderElement> expectElementsThatAreNot100Continue = new ArrayList<HeaderElement>();
for (final Header h : expectHeaders) {
for (final HeaderElement elt : h.getElements()) {
if (!(HTTP.EXPECT_CONTINUE.equalsIgnoreCase(elt.getName()))) {
expectElementsThatAreNot100Continue.add(elt);
} else {
hasHeader = true;
}
}
if (hasHeader) {
request.removeHeader(h);
for (final HeaderElement elt : expectElementsThatAreNot100Continue) {
final BasicHeader newHeader = new BasicHeader(HTTP.EXPECT_DIRECTIVE, elt.getName());
request.addHeader(newHeader);
}
return;
} else {
expectElementsThatAreNot100Continue = new ArrayList<HeaderElement>();
}
}
}
代码示例来源:origin: org.apache.httpcomponents/com.springsource.org.apache.httpcomponents.httpclient-cache
private void remove100ContinueHeaderIfExists(HttpRequest request) {
boolean hasHeader = false;
Header[] expectHeaders = request.getHeaders(HTTP.EXPECT_DIRECTIVE);
List<HeaderElement> expectElementsThatAreNot100Continue = new ArrayList<HeaderElement>();
for (Header h : expectHeaders) {
for (HeaderElement elt : h.getElements()) {
if (!(HTTP.EXPECT_CONTINUE.equalsIgnoreCase(elt.getName()))) {
expectElementsThatAreNot100Continue.add(elt);
} else {
hasHeader = true;
}
}
if (hasHeader) {
request.removeHeader(h);
for (HeaderElement elt : expectElementsThatAreNot100Continue) {
BasicHeader newHeader = new BasicHeader(HTTP.EXPECT_DIRECTIVE, elt.getName());
request.addHeader(newHeader);
}
return;
} else {
expectElementsThatAreNot100Continue = new ArrayList<HeaderElement>();
}
}
}
代码示例来源:origin: com.ibm.sbt/com.ibm.sbt.core
Header[] header = request.getHeaders("authorization");
for (int i = 0; i < header.length; i++) {
request.removeHeader(header[i]);
代码示例来源:origin: wso2/wso2-synapse
httpRequest.getFirstHeader(HTTPConstants.HEADER_SOAP_ACTION);
if (existingHeader != null) {
httpRequest.removeHeader(existingHeader);
代码示例来源:origin: com.ibm.sbt/com.ibm.sbt.core
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
// Add Security headers
try {
if (null == token.getAccessToken()) {
return;
}
} catch (Exception e) {
Platform.getInstance().log(e);
return;
}
// Remove any existing authorization headers which can cause oauth requests to fail
if(request.containsHeader("authorization")){
Header[] header = request.getHeaders("authorization");
for (int i = 0; i < header.length; i++) {
request.removeHeader(header[i]);
}
}
String authorizationheader = "Bearer " + token.getAccessToken();
request.addHeader("Authorization", authorizationheader);
}
}
代码示例来源:origin: wso2/wso2-synapse
request.getFirstHeader(HTTPConstants.HEADER_SOAP_ACTION);
if (existingHeader != null) {
request.removeHeader(existingHeader);
内容来源于网络,如有侵权,请联系作者删除!