Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minor updates; begin to pass back HTTP status in success case

  • Loading branch information...
commit fdb4255f36d374c3920a4d0343888b9b9aab910f 1 parent 6246d29
@tomwhipple authored
View
8 .classpath
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="src" path="examples"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
View
3  .gitignore
@@ -6,4 +6,5 @@ build
local.properties
bin/
gen/
-_layouts
+_layouts
+.classpath
View
12 src/com/loopj/android/http/AsyncHttpResponseHandler.java
@@ -131,7 +131,7 @@ public void onFailure(Throwable error, String content) {
// Pre-processing of messages (executes in background threadpool thread)
//
- protected void sendSuccessMessage(String responseBody) {
+ protected void sendSuccessMessage(int httpStatus, String responseBody) {
sendMessage(obtainMessage(SUCCESS_MESSAGE, responseBody));
}
@@ -194,7 +194,7 @@ protected Message obtainMessage(int responseMessage, Object response) {
if(handler != null){
msg = this.handler.obtainMessage(responseMessage, response);
}else{
- msg = new Message();
+ msg = Message.obtain(); // The preferred way to get a new Message.
msg.what = responseMessage;
msg.obj = response;
}
@@ -217,10 +217,14 @@ void sendResponseMessage(HttpResponse response) {
sendFailureMessage(e, null);
}
- if(status.getStatusCode() >= 300) {
+ /* According to http://developer.android.com/reference/org/apache/http/client/HttpResponseException.html
+ * This exception should be thrown for non HTTP 2** responses.
+ */
+ int httpStatus = status.getStatusCode();
+ if(httpStatus < 200 || 300 <= httpStatus) {
sendFailureMessage(new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), responseBody);
} else {
- sendSuccessMessage(responseBody);
+ sendSuccessMessage(httpStatus, responseBody);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.