@@ -104,13 +104,13 @@ static class ResponderHandler extends Handler {
104
104
ResponderHandler (AsyncHttpResponseHandler service ) {
105
105
mResponder = new WeakReference <AsyncHttpResponseHandler >(service );
106
106
}
107
+
107
108
@ Override
108
- public void handleMessage (Message msg )
109
- {
109
+ public void handleMessage (Message msg ) {
110
110
AsyncHttpResponseHandler service = mResponder .get ();
111
- if (service != null ) {
112
- service .handleMessage (msg );
113
- }
111
+ if (service != null ) {
112
+ service .handleMessage (msg );
113
+ }
114
114
}
115
115
}
116
116
@@ -216,9 +216,9 @@ public void onSuccess(int statusCode, String content) {
216
216
/**
217
217
* Fired when a request returns successfully, override to handle in your own code
218
218
*
219
- * @param statusCode the status code of the response
220
- * @param headers return headers, if any
221
- * @param responseBody the body of the HTTP response from the server
219
+ * @param statusCode the status code of the response
220
+ * @param headers return headers, if any
221
+ * @param responseBody the body of the HTTP response from the server
222
222
*/
223
223
public void onSuccess (int statusCode , Header [] headers , byte [] responseBody ) {
224
224
try {
@@ -229,6 +229,7 @@ public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
229
229
onFailure (statusCode , headers , e , (String ) null );
230
230
}
231
231
}
232
+
232
233
/**
233
234
* Fired when a request fails to complete, override to handle in your own code
234
235
*
@@ -284,29 +285,28 @@ public void onFailure(int statusCode, Header[] headers, Throwable error, String
284
285
/**
285
286
* Fired when a request fails to complete, override to handle in your own code
286
287
*
287
- * @param statusCode return HTTP status code
288
- * @param headers return headers, if any
289
- * @param responseBody the response body, if any
290
- * @param error the underlying cause of the failure
288
+ * @param statusCode return HTTP status code
289
+ * @param headers return headers, if any
290
+ * @param responseBody the response body, if any
291
+ * @param error the underlying cause of the failure
291
292
*/
292
293
public void onFailure (int statusCode , Header [] headers , byte [] responseBody , Throwable error ) {
293
294
String response = null ;
294
295
try {
295
296
response = new String (responseBody , getCharset ());
297
+ onFailure (statusCode , headers , error , response );
296
298
} catch (UnsupportedEncodingException e ) {
297
299
Log .e (LOG_TAG , e .toString ());
298
300
onFailure (statusCode , headers , e , null );
299
301
}
300
- onFailure (statusCode , headers , error , response );
301
302
}
302
303
303
304
/**
304
305
* Fired when a retry occurs, override to handle in your own code
305
- *
306
306
*/
307
307
public void onRetry () {
308
308
}
309
-
309
+
310
310
311
311
//
312
312
// Pre-processing of messages (executes in background threadpool thread)
@@ -333,9 +333,9 @@ protected void sendFinishMessage() {
333
333
}
334
334
335
335
protected void sendRetryMessage () {
336
- sendMessage (obtainMessage (RETRY_MESSAGE , null ));
336
+ sendMessage (obtainMessage (RETRY_MESSAGE , null ));
337
337
}
338
-
338
+
339
339
// Methods which emulate android's Handler and Message methods
340
340
protected void handleMessage (Message msg ) {
341
341
Object [] response ;
@@ -361,7 +361,7 @@ protected void handleMessage(Message msg) {
361
361
break ;
362
362
case RETRY_MESSAGE :
363
363
onRetry ();
364
- break ;
364
+ break ;
365
365
}
366
366
}
367
367
@@ -423,7 +423,7 @@ byte[] getResponseData(HttpEntity entity) throws IOException {
423
423
if (contentLength < 0 ) {
424
424
contentLength = BUFFER_SIZE ;
425
425
}
426
- try {
426
+ try {
427
427
ByteArrayBuffer buffer = new ByteArrayBuffer ((int ) contentLength );
428
428
try {
429
429
byte [] tmp = new byte [BUFFER_SIZE ];
@@ -438,7 +438,7 @@ byte[] getResponseData(HttpEntity entity) throws IOException {
438
438
instream .close ();
439
439
}
440
440
responseBody = buffer .buffer ();
441
- } catch ( OutOfMemoryError e ) {
441
+ } catch ( OutOfMemoryError e ) {
442
442
System .gc ();
443
443
throw new IOException ("File too large to fit into available memory" );
444
444
}
0 commit comments