Skip to content

Additional Information in AsyncHttpResponseHandler #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shnhrrsn opened this issue Aug 27, 2011 · 7 comments
Closed

Additional Information in AsyncHttpResponseHandler #14

shnhrrsn opened this issue Aug 27, 2011 · 7 comments

Comments

@shnhrrsn
Copy link

It's posible I'm missing something, but I don't see anyway to get any additional information bout the request's response.

I'm specifically needing two things:

  • HTTP Status Code in both onSuccess and onError: Casting the throwable in onError to HttpResponseException will let me call getStatusCode(), but this really isn't the cleanest way to go about it
  • Response bodies in onError: RESTful API's frequently send back a response message, along with an HTTP error code.

Bonus: A way to fetch HTTP Response headers in both methods.

@Jenus
Copy link

Jenus commented Oct 27, 2011

It is my need, too.

@tunix
Copy link

tunix commented Feb 21, 2012

+1 -- Why is sendResponseMessage in AsyncHttpResponseHandler.java so restrictive? Defining it as protected would be nicer so that we could at least have a chance to get headers before further processing.

@tobiasschuerg
Copy link

I would need that too.

@twaddington
Copy link

@tunix I submitted a pull request that updates the AsyncHttpResponseHandler#sendResponseMessage method to protected. I'm having the same issue where I need access to the status code and response headers.

#83

@emanuelef
Copy link

Same need, is it something still in progress? Tx

@tobiasschuerg
Copy link

I founf zanfas Bruch of async-http very useful.
Am 10.09.2012 05:57 schrieb "Emanuele Fumagalli" notifications@github.com:

Same need, is it something still in progress? Tx


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-8420113.

@smarek
Copy link
Member

smarek commented Oct 13, 2013

@twaddington I've merged your request (manually though).

I agree, REST services returns response bodies on various states (even in cases of errors, which I don't think is a good practice), and here you go, onFailure has been given two params, Throwable error and String responseBody.

About the status code, I've added compatible changes, to include various methods onFailure to obtain reponse headers (Header[]) and HTTP status code (int), see the linked commit. onSuccess had these fields already.

I consider this issue as closed.

@smarek smarek closed this as completed Oct 13, 2013
smarek added a commit that referenced this issue Oct 13, 2013
iNdieboyjeff pushed a commit to iNdieboyjeff/android-async-http that referenced this issue Oct 14, 2013
# By mareksebera (51) and Marek Sebera (2)
# Via mareksebera
* 'master' of https://github.com/loopj/android-async-http: (53 commits)
  Handy method to specify charset in anonymous inner instances
  Sample Application initial state
  Removed unnecessary dependency, android-async-http#168
  Javadoc formatting
  Fixed 2d34e1c leftover, Closes android-async-http#86
  Fixing android-async-http#79, Allowing non-standard HTTP and HTTPS ports
  Added warning about SSL bypass fix
  Related to android-async-http#67, avoiding NPE in JsonHttpResponseHandler
  Fixes android-async-http#61, allow removing of Basic Auth credentials
  Compatibility changes fix
  Fixes android-async-http#14
  Fixes android-async-http#143
  android-async-http#88 uncatched exception
  Closes android-async-http#266
  Closes android-async-http#283
  Fixes android-async-http#286
  Fixes android-async-http#294
  Fixes android-async-http#287
  Fixes android-async-http#295
  Added Maven description to README file [skip ci]
  ...

Conflicts:
	.classpath
	build.gradle
	project.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants