From 5d821fb9985775534a77608f30cd685d4dd46b3a Mon Sep 17 00:00:00 2001 From: Tristan Waddington Date: Thu, 16 Aug 2012 16:44:53 -0700 Subject: [PATCH 1/4] Fix a spelling error in the Javadoc for the setTimeout method. --- src/com/loopj/android/http/AsyncHttpClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/loopj/android/http/AsyncHttpClient.java b/src/com/loopj/android/http/AsyncHttpClient.java index 54e14b962..017a30843 100644 --- a/src/com/loopj/android/http/AsyncHttpClient.java +++ b/src/com/loopj/android/http/AsyncHttpClient.java @@ -216,7 +216,7 @@ public void setUserAgent(String userAgent) { } /** - * Sets the connection time oout. By default, 10 seconds + * Set the connection timeout. By default, 10 seconds. * @param timeout the connect/socket timeout in milliseconds */ public void setTimeout(int timeout){ From f9a2f09ca8f0281ec25d8fab2236fb115a469d60 Mon Sep 17 00:00:00 2001 From: Tristan Waddington Date: Tue, 21 Aug 2012 15:05:25 -0700 Subject: [PATCH 2/4] Update the 'sendResponseMessage' with the 'protected' modifier so subclasses can override the method's functionality. --- src/com/loopj/android/http/AsyncHttpResponseHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/loopj/android/http/AsyncHttpResponseHandler.java b/src/com/loopj/android/http/AsyncHttpResponseHandler.java index 1c98434f8..718a709ff 100644 --- a/src/com/loopj/android/http/AsyncHttpResponseHandler.java +++ b/src/com/loopj/android/http/AsyncHttpResponseHandler.java @@ -207,7 +207,7 @@ protected Message obtainMessage(int responseMessage, Object response) { // Interface to AsyncHttpRequest - void sendResponseMessage(HttpResponse response) { + protected void sendResponseMessage(HttpResponse response) { StatusLine status = response.getStatusLine(); String responseBody = null; try { @@ -227,4 +227,4 @@ void sendResponseMessage(HttpResponse response) { sendSuccessMessage(responseBody); } } -} \ No newline at end of file +} From d983537c62f7f4c5079355f8017a5e179f9bc778 Mon Sep 17 00:00:00 2001 From: Tristan Waddington Date: Wed, 22 Aug 2012 15:21:02 -0700 Subject: [PATCH 3/4] Add the protected modifier to the binary response handler's sendResponseMessage method to match the change made to the parent class. --- src/com/loopj/android/http/BinaryHttpResponseHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/loopj/android/http/BinaryHttpResponseHandler.java b/src/com/loopj/android/http/BinaryHttpResponseHandler.java index 967f632e9..b066ceb37 100644 --- a/src/com/loopj/android/http/BinaryHttpResponseHandler.java +++ b/src/com/loopj/android/http/BinaryHttpResponseHandler.java @@ -142,7 +142,7 @@ protected void handleMessage(Message msg) { } // Interface to AsyncHttpRequest - void sendResponseMessage(HttpResponse response) { + protected void sendResponseMessage(HttpResponse response) { StatusLine status = response.getStatusLine(); Header[] contentTypeHeaders = response.getHeaders("Content-Type"); byte[] responseBody = null; From 1414edfdb76f06dbcb6478323e8fa1931bb1d24f Mon Sep 17 00:00:00 2001 From: Tristan Waddington Date: Wed, 22 Aug 2012 15:29:57 -0700 Subject: [PATCH 4/4] Convert tabs to spaces and fix some formatting in the JSON response handler class. --- .../android/http/JsonHttpResponseHandler.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/loopj/android/http/JsonHttpResponseHandler.java b/src/com/loopj/android/http/JsonHttpResponseHandler.java index 8cdd4ffbf..52dd54e15 100644 --- a/src/com/loopj/android/http/JsonHttpResponseHandler.java +++ b/src/com/loopj/android/http/JsonHttpResponseHandler.java @@ -107,12 +107,14 @@ protected void handleSuccessJsonMessage(Object jsonResponse) { protected Object parseResponse(String responseBody) throws JSONException { Object result = null; - //trim the string to prevent start with blank, and test if the string is valid JSON, because the parser don't do this :(. If Json is not valid this will return null - responseBody = responseBody.trim(); - if(responseBody.startsWith("{") || responseBody.startsWith("[")) { - result = new JSONTokener(responseBody).nextValue(); - } - return result; + // trim the string to prevent start with blank, and test if the string + // is valid JSON, because the parser don't do this :(. If Json is not + // valid this will return null + responseBody = responseBody.trim(); + if (responseBody.startsWith("{") || responseBody.startsWith("[")) { + result = new JSONTokener(responseBody).nextValue(); + } + return result; } @Override