当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequest.removeHeaders方法代码示例

本文整理汇总了Java中org.apache.http.HttpRequest.removeHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest.removeHeaders方法的具体用法?Java HttpRequest.removeHeaders怎么用?Java HttpRequest.removeHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.removeHeaders方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.http.HttpRequest; //导入方法依赖的package包/类
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    if(StringUtils.contains(request.getRequestLine().getUri(), "b2_authorize_account")) {
        // Skip setting token for
        if(log.isDebugEnabled()) {
            log.debug("Skip setting token in b2_authorize_account");
        }
        return;
    }
    switch(request.getRequestLine().getMethod()) {
        case "POST":
            // Do not override Authorization header for upload requests with upload URL token
            break;
        default:
            if(StringUtils.isNotBlank(authorizationToken)) {
                request.removeHeaders(HttpHeaders.AUTHORIZATION);
                request.addHeader(HttpHeaders.AUTHORIZATION, authorizationToken);
            }
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:21,代码来源:B2ErrorResponseInterceptor.java

示例2: process

import org.apache.http.HttpRequest; //导入方法依赖的package包/类
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    if(tokens.isExpired()) {
        try {
            tokens = this.refresh(tokens);
        }
        catch(BackgroundException e) {
            log.warn(String.format("Failure refreshing OAuth 2 tokens. %s", e.getDetail()));
            throw new IOException(e);
        }
    }
    if(StringUtils.isNotBlank(tokens.getAccessToken())) {
        if(log.isInfoEnabled()) {
            log.info(String.format("Authorizing service request with OAuth2 access token %s", tokens.getAccessToken()));
        }
        request.removeHeaders(HttpHeaders.AUTHORIZATION);
        request.addHeader(new BasicHeader(HttpHeaders.AUTHORIZATION, String.format("Bearer %s", tokens.getAccessToken())));
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:20,代码来源:OAuth2RequestInterceptor.java

示例3: afterPreCap

import org.apache.http.HttpRequest; //导入方法依赖的package包/类
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {

    if (args.length < 2) {
        return;
    }

    /**
     * after precap the client's span is created, set the span meta into http request header
     */
    String url = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY);

    Span span = this.spanFactory.getSpanFromContext(url);

    String spanMeta = this.spanFactory.getSpanMeta(span);

    HttpRequest request = (HttpRequest) args[1];

    request.removeHeaders(InvokeChainConstants.PARAM_HTTPHEAD_SPANINFO);
    request.addHeader(InvokeChainConstants.PARAM_HTTPHEAD_SPANINFO, spanMeta);

    handleSlowOperSupporter(request, span, context);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:24,代码来源:ApacheHttpClientAdapter.java

示例4: process

import org.apache.http.HttpRequest; //导入方法依赖的package包/类
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    if(StringUtils.isNotBlank(token)) {
        request.removeHeaders(SDSSession.SDS_AUTH_TOKEN_HEADER);
        request.addHeader(SDSSession.SDS_AUTH_TOKEN_HEADER, token);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:8,代码来源:SDSErrorResponseInterceptor.java

示例5: process

import org.apache.http.HttpRequest; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context)
        throws HttpException, IOException {
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    if (request instanceof HttpEntityEnclosingRequest) {
        if (this.overwrite) {
            request.removeHeaders(HTTP.TRANSFER_ENCODING);
            request.removeHeaders(HTTP.CONTENT_LEN);
        } else {
            if (request.containsHeader(HTTP.TRANSFER_ENCODING)) {
                throw new ProtocolException("Transfer-encoding header already present");
            }
            if (request.containsHeader(HTTP.CONTENT_LEN)) {
                throw new ProtocolException("Content-Length header already present");
            }
        }
        ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
        HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
        if (entity == null) {
            request.addHeader(HTTP.CONTENT_LEN, "0");
            return;
        }
        // Must specify a transfer encoding or a content length
        if (entity.isChunked() || entity.getContentLength() < 0) {
            if (ver.lessEquals(HttpVersion.HTTP_1_0)) {
                throw new ProtocolException(
                        "Chunked transfer encoding not allowed for " + ver);
            }
            request.addHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
        } else {
            request.addHeader(HTTP.CONTENT_LEN, Long.toString(entity.getContentLength()));
        }
        // Specify a content type if known
        if (entity.getContentType() != null && !request.containsHeader(
                HTTP.CONTENT_TYPE )) {
            request.addHeader(entity.getContentType());
        }
        // Specify a content encoding if known
        if (entity.getContentEncoding() != null && !request.containsHeader(
                HTTP.CONTENT_ENCODING)) {
            request.addHeader(entity.getContentEncoding());
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:RequestContent.java


注:本文中的org.apache.http.HttpRequest.removeHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。