surjit / oauth

Automatically exported from code.google.com/p/oauth
0 stars 0 forks source link

JAVA library: OAuthProblemException should provide unparsed response body #99

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Use the OAuth client library on a web service that returns a status code
indicating error (e.g. 401) and a textual error message in the body. 

What is the expected output? What do you see instead?
Expected: The client throws an OAuthProblemException which contains the
error message.
Instead: The response body is not accessible if it does not contain
parseable parameters.

What version of the product are you using? On what operating system?
r958 on Linux

Please provide any additional information below.
The OAuthProblemException should not only contain the parsed body
(accessible via getParameters(), as far as I understand), but also the raw
response body. This also means that
OAuthResponseMessage.toOAuthProblemException() has to be changed such that
it includes the unparsed body in the exception.

Currently, the response body is parsed when generating the
OAuthProblemException. This should probably be changed; instead, the
OAuthProblemException should only contain a reference to the InputStream
from getBodyAsStream and either parse the parameters or return the
InputStream, depending on what the user wants from the OAuthProblemException.

Original issue reported on code.google.com by gubler.d...@gmail.com on 15 Apr 2009 at 10:23

GoogleCodeExporter commented 8 years ago

Original comment by morten.f...@gmail.com on 16 May 2009 at 2:55

GoogleCodeExporter commented 8 years ago
Use OAuthClient.access (not OAuthClient.invoke).  It returns the response 
without 
attempting to parse the body.

Sadly, you might not get the response body from a URLConnectionClient, because 
the 
underlying HttpURLConnection doesn't deliver the body if the response status 
code 
isn't 2xx (success).  I've noticed this deficiency in some J2SE implementations 
of 
HttpURLConnection.  I get better results with HttpClient3 or HttpClient4 
(instead of 
URLConnectionClient).

By the way, the OAuthProblemException returned by 
OAuthResponseMessage.toOAuthProblemException may contain an excerpt of the 
response 
body, as part of the parameter named HttpMessage.RESPONSE.  This can help you 
understand what happened, although it's not a substitute for the complete body.

Original comment by jmkrist...@gmail.com on 29 May 2009 at 5:18