Repository navigation
DG-12631 improvements - #2
Closed
patrick-webs wants to merge 2 commits into
Closed
patrick-webs wants to merge 2 commits into
patrick-webs wants to merge 2 commits into
Conversation
The Async client was suppressing the response body before calling codecould look at it; this was complicating the debugging of a HTTP 404 Not Found that the client was receiving from CloudFlare.
Owner
|
I was able to take a different approach and get the async version to behave the same as the synchronous version upon an exception, namely making the parsed response available via a call to Future future = // some async call
try {
future.get();
} catch (ExecutionException ex) {
HttpResponseException unwrapped = (HttpResponseException) ex.getCause();
Map parsedErrorResponse = (Map) unwrapped.getResponse().getData();
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found that this code in in
http-builder-0.7.2-sources.jar!/groovyx/net/http/HTTPBuilder.java:prevents accessing the content of the response using code such as
It fails with a
java.io.IOException: Attempted read from closed streamerror.It seems like the solution is to use a different response handler that doesn't throw an
groovyx.net.http.HttpResponseException, but rather throws an exception that includes the body content as a string. After making these changes I was successfully able to get the full HTTP response body from an exception thrown by the async client in my own app.