本文整理汇总了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()));
}
}
}
}
示例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;
}