Skip to content
Open

d #31

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/com/androidquery/callback/AbstractAjaxCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -1336,31 +1336,38 @@ private void httpDo(HttpUriRequest hr, String url, Map<String, String> headers,
String message = response.getStatusLine().getReasonPhrase();
String error = null;

HttpEntity entity = response.getEntity();
InputStream is = null;

if(code < 200 || code >= 300){

try{
HttpEntity entity = response.getEntity();
byte[] s = AQUtility.toBytes(entity.getContent());
error = new String(s, "UTF-8");

byte[] s = null;
Header encoding = entity.getContentEncoding();
if(encoding != null && encoding.getValue().equalsIgnoreCase("gzip")) {
is = new GZIPInputStream(entity.getContent());
s = AQUtility.toBytes(is);
} else
s = AQUtility.toBytes(entity.getContent());

error = new String(s, "UTF-8");
AQUtility.debug("error", error);

}catch(Exception e){
AQUtility.debug(e);
}


}else{

HttpEntity entity = response.getEntity();

HttpHost currentHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
redirect = currentHost.toURI() + currentReq.getURI();

int size = Math.max(32, Math.min(1024 * 64, (int) entity.getContentLength()));

OutputStream os = null;
InputStream is = null;

try{

Expand Down