Skip to content

Commit d138635

Browse files
committed
Merge branch 'master' of github.com:loopj/android-async-http
2 parents 5ca0245 + 72bb013 commit d138635

File tree

24 files changed

+227
-36
lines changed

24 files changed

+227
-36
lines changed

library/src/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,8 @@ public void onFailure(int statusCode, Header[] headers, Throwable error, String
291291
* @param error the underlying cause of the failure
292292
*/
293293
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
294-
String response;
295294
try {
296-
response = new String(responseBody, getCharset());
295+
String response = responseBody == null ? null : new String(responseBody, getCharset());
297296
onFailure(statusCode, headers, error, response);
298297
} catch (UnsupportedEncodingException e) {
299298
Log.e(LOG_TAG, e.toString());

library/src/com/loopj/android/http/TextHttpResponseHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public void onSuccess(int statusCode, Header[] headers, String responseBody) {
100100
@Override
101101
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
102102
try {
103-
onSuccess(statusCode, headers, new String(responseBody, getCharset()));
103+
String response = responseBody == null ? null : new String(responseBody, getCharset());
104+
onSuccess(statusCode, headers, response);
104105
} catch (UnsupportedEncodingException e) {
105106
Log.v(LOG_TAG, "String encoding failed, calling onFailure(int, Header[], String, Throwable)");
106107
onFailure(0, headers, (String) null, e);
@@ -110,7 +111,8 @@ public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
110111
@Override
111112
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
112113
try {
113-
onFailure(statusCode, headers, new String(responseBody, getCharset()), error);
114+
String response = responseBody == null ? null : new String(responseBody, getCharset());
115+
onFailure(statusCode, headers, response, error);
114116
} catch (UnsupportedEncodingException e) {
115117
Log.v(LOG_TAG, "String encoding failed, calling onFailure(int, Header[], String, Throwable)");
116118
onFailure(0, headers, (String) null, e);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
android:versionCode="1"
55
android:versionName="1.0">
66

7-
<permission android:name="android.permission.INTERNET" />
7+
<uses-permission android:name="android.permission.INTERNET"/>
88

99
<uses-sdk
1010
android:minSdkVersion="3"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
<string name="app_name">Android Async Http Sample</string>
55
<string name="title_get_sample">GET Sample</string>
66
<string name="title_json_sample">JSON Sample</string>
7-
7+
<string name="title_post_sample">POST Sample</string>
8+
<string name="title_put_sample">PUT Sample</string>
9+
<string name="title_delete_sample">DELETE Sample</string>
810
</resources>

0 commit comments

Comments
 (0)