Skip to content

Commit c40ade9

Browse files
committed
Merge pull request android-async-http#54 from MasterXval/master
Corrected NullPointerException on request with 204 http status
2 parents f2fd6db + 6cf3742 commit c40ade9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ public void process(HttpRequest request, HttpContext context) {
146146
httpClient.addResponseInterceptor(new HttpResponseInterceptor() {
147147
public void process(HttpResponse response, HttpContext context) {
148148
final HttpEntity entity = response.getEntity();
149+
if (entity == null) {
150+
return;
151+
}
149152
final Header encoding = entity.getContentEncoding();
150153
if (encoding != null) {
151154
for (HeaderElement element : encoding.getElements()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ void sendResponseMessage(HttpResponse response) {
211211
HttpEntity temp = response.getEntity();
212212
if(temp != null) {
213213
entity = new BufferedHttpEntity(temp);
214+
responseBody = EntityUtils.toString(entity);
214215
}
215-
responseBody = EntityUtils.toString(entity);
216216
} catch(IOException e) {
217217
sendFailureMessage(e, null);
218218
}

0 commit comments

Comments
 (0)