Skip to content

Commit af9a1f5

Browse files
committed
Added BlackholeHttpResponseHandler for when you want to ignore response to your request, android-async-http#416
1 parent b2080c0 commit af9a1f5

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Regression fix on onProgress(int,int) documentation
1111
- Sample application now can be built with LeakCanary, use i.e. `gradle :sample:installWithLeakCanaryDebug` to use it
1212
- Updated RequestParams documentation on handling arrays, sets and maps, along with new RequestParamsDebug sample
13+
- Added BlackholeHttpResponseHandler implementation, which discards all response contents and silents all various log messages (see #416)
1314

1415
## 1.4.7 (released 9. 5. 2015)
1516

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.loopj.android.http;
2+
3+
import org.apache.http.Header;
4+
import org.apache.http.HttpResponse;
5+
6+
/**
7+
* Blank implementation of ResponseHandlerInterface, which ignores all contents returned by
8+
* remote HTTP endpoint, and discards all various log messages
9+
* <p>&nbsp;</p>
10+
* Use this implementation, if you deliberately want to ignore all response, because you cannot
11+
* pass null ResponseHandlerInterface into AsyncHttpClient implementation
12+
*/
13+
public class BlackholeHttpResponseHandler extends AsyncHttpResponseHandler {
14+
15+
@Override
16+
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
17+
18+
}
19+
20+
@Override
21+
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
22+
23+
}
24+
25+
@Override
26+
public void onProgress(long bytesWritten, long totalSize) {
27+
28+
}
29+
30+
@Override
31+
public void onCancel() {
32+
33+
}
34+
35+
@Override
36+
public void onFinish() {
37+
38+
}
39+
40+
@Override
41+
public void onPostProcessResponse(ResponseHandlerInterface instance, HttpResponse response) {
42+
43+
}
44+
45+
@Override
46+
public void onPreProcessResponse(ResponseHandlerInterface instance, HttpResponse response) {
47+
48+
}
49+
50+
@Override
51+
public void onRetry(int retryNo) {
52+
53+
}
54+
55+
@Override
56+
public void onStart() {
57+
58+
}
59+
60+
@Override
61+
public void onUserException(Throwable error) {
62+
63+
}
64+
}

0 commit comments

Comments
 (0)