Skip to content

Commit cc740d1

Browse files
committed
NPE fix in AsyncHttpResponseHandler, Fixes android-async-http#351
1 parent d89cca6 commit cc740d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void setCharset(final String charset) {
139139
}
140140

141141
public String getCharset() {
142-
return this.responseCharset;
142+
return this.responseCharset == null ? DEFAULT_CHARSET : this.responseCharset;
143143
}
144144

145145
/**
@@ -222,7 +222,7 @@ public void onSuccess(int statusCode, String content) {
222222
*/
223223
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
224224
try {
225-
String response = new String(responseBody, getCharset());
225+
String response = responseBody == null ? null : new String(responseBody, getCharset());
226226
onSuccess(statusCode, headers, response);
227227
} catch (UnsupportedEncodingException e) {
228228
Log.e(LOG_TAG, e.toString());

0 commit comments

Comments
 (0)