hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaun A Elliott (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1581) change scope of ContentResponseHandler or provide an alternative
Date Mon, 24 Nov 2014 17:14:12 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1581?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14223149#comment-14223149
] 

Shaun A Elliott commented on HTTPCLIENT-1581:
---------------------------------------------

{quote}
The only way to get around this is to go back to the non-fluent api and get the HttpResponse,
pull the entity, check it, etc. This is already done in ContentResponseHandler and is a clear
DRY violation.
{quote}

The implication is a custom ResponseHandler, as you've asked:
{quote}
Why can't you just use a custom ResponseHandler? 
{quote}

But, as I said before, a custom ResponseHandler is just going to do most (if not all) of what
ContentResponseHandler does. This is a DRY violation. 

More succinctly, why would I want to re-write\copy what ContentResponseHandler does if I only
need to change it's behavior slightly? This is a fairly clear case for polymorphism as I see
it.

> change scope of ContentResponseHandler or provide an alternative
> ----------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1581
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1581
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: Fluent HC
>            Reporter: Shaun A Elliott
>
> As a developer using the apache fluent hc library I need to be able to get back both
the http status code and the http response body. 
> When I try to do this now, I get an exception that "Response content has been already
consumed". 
> The only way to get around this is to go back to the non-fluent api and get the HttpResponse,
pull the entity, check it, etc. This is already done in ContentResponseHandler and is a clear
DRY violation. 
> It would be much cleaner to expose ContentResponseHandler as a public class, so that
it can be overriden, called from handleContent, etc. Or to add a new ResponseHandler that
also provides other details like the response code.
> Consider these stackoverflow questions as I'm not the only one who desires this:
> http://stackoverflow.com/questions/22409303/is-it-possible-to-get-both-the-status-code-and-the-body-content-when-using-apach
> http://stackoverflow.com/questions/14024625/how-to-get-httpclient-returning-status-code-and-response-body



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message