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


Java HttpResponse.getFirstHeader方法代码示例

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


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

示例1: sendResponseMessage

import cz.msebera.android.httpclient.HttpResponse; //导入方法依赖的package包/类
@Override
public void sendResponseMessage(HttpResponse response) throws IOException {
    if (!Thread.currentThread().isInterrupted()) {
        StatusLine status = response.getStatusLine();
        if (status.getStatusCode() == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) {
            //already finished
            if (!Thread.currentThread().isInterrupted())
                sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), null);
        } else if (status.getStatusCode() >= 300) {
            if (!Thread.currentThread().isInterrupted())
                sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), null, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()));
        } else {
            if (!Thread.currentThread().isInterrupted()) {
                Header header = response.getFirstHeader(AsyncHttpClient.HEADER_CONTENT_RANGE);
                if (header == null) {
                    append = false;
                    current = 0;
                } else {
                    AsyncHttpClient.log.v(LOG_TAG, AsyncHttpClient.HEADER_CONTENT_RANGE + ": " + header.getValue());
                }
                sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), getResponseData(response.getEntity()));
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RangeFileAsyncHttpResponseHandler.java

示例2: extractUrls

import cz.msebera.android.httpclient.HttpResponse; //导入方法依赖的package包/类
public static String extractUrls(HttpResponse response) {
    String found = null;
    try {
        Scanner scan;
        Header contentEncoding = response
                .getFirstHeader("Content-Encoding");
        if (contentEncoding != null
                && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
            scan = new Scanner(new GZIPInputStream(response.getEntity()
                    .getContent()));
        } else {
            scan = new Scanner(response.getEntity().getContent());
        }

        found = scan.findWithinHorizon(url_match_pattern, 0);
        if (null != found) {
            Matcher m = url_match_pattern.matcher(found);
            if (m.matches())
                found = m.group(1);
        }
        scan.close();
        EntityUtils.consume(response.getEntity());
    } catch (Throwable t) {
        Log.e(LOG_TAG, "Error Occurred", t);
    }
    return found;
}
 
开发者ID:smarek,项目名称:Simple-Dilbert,代码行数:28,代码来源:FindUrls.java


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