本文整理汇总了Java中cz.msebera.android.httpclient.client.HttpResponseException类的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseException类的具体用法?Java HttpResponseException怎么用?Java HttpResponseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpResponseException类属于cz.msebera.android.httpclient.client包,在下文中一共展示了HttpResponseException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendResponseMessage
import cz.msebera.android.httpclient.client.HttpResponseException; //导入依赖的package包/类
@Override
public void sendResponseMessage(HttpResponse response) throws IOException {
// do not process if request has been cancelled
if (!Thread.currentThread().isInterrupted()) {
StatusLine status = response.getStatusLine();
byte[] responseBody;
responseBody = getResponseData(response.getEntity());
// additional cancellation check as getResponseData() can take non-zero time to process
if (!Thread.currentThread().isInterrupted()) {
if (status.getStatusCode() >= 300) {
sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), responseBody, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()));
} else {
sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), responseBody);
}
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AsyncHttpResponseHandler.java
示例2: sendResponseMessage
import cz.msebera.android.httpclient.client.HttpResponseException; //导入依赖的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
示例3: sendResponseMessage
import cz.msebera.android.httpclient.client.HttpResponseException; //导入依赖的package包/类
@Override
public final void sendResponseMessage(HttpResponse response) throws IOException {
StatusLine status = response.getStatusLine();
Header[] contentTypeHeaders = response.getHeaders(AsyncHttpClient.HEADER_CONTENT_TYPE);
if (contentTypeHeaders.length != 1) {
//malformed/ambiguous HTTP Header, ABORT!
sendFailureMessage(
status.getStatusCode(),
response.getAllHeaders(),
null,
new HttpResponseException(
status.getStatusCode(),
"None, or more than one, Content-Type Header found!"
)
);
return;
}
Header contentTypeHeader = contentTypeHeaders[0];
boolean foundAllowedContentType = false;
for (String anAllowedContentType : getAllowedContentTypes()) {
try {
if (Pattern.matches(anAllowedContentType, contentTypeHeader.getValue())) {
foundAllowedContentType = true;
}
} catch (PatternSyntaxException e) {
AsyncHttpClient.log.e(LOG_TAG, "Given pattern is not valid: " + anAllowedContentType, e);
}
}
if (!foundAllowedContentType) {
//Content-Type not in allowed list, ABORT!
sendFailureMessage(
status.getStatusCode(),
response.getAllHeaders(),
null,
new HttpResponseException(
status.getStatusCode(),
"Content-Type (" + contentTypeHeader.getValue() + ") not allowed!"
)
);
return;
}
super.sendResponseMessage(response);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:BinaryHttpResponseHandler.java
注:本文中的cz.msebera.android.httpclient.client.HttpResponseException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论