On Thu, 2023-08-31 at 10:08 +0200, Konrad Windszus wrote:
> Hi,
> I can pass a FutureCallback implementation to
> HttpAsyncClient.execute(…).
> However the javadoc at
> https://hc.apache.org/httpcomponents-core-5.1.x/current/httpcore5/apidocs/org/apache/hc/core5/concurrent/FutureCallback.html
>  is very sparse.
> Particularly the following questions are not answered:
> 
> 1) Is "completed(HttpResponse)" only called for success status codes
> or for all kinds server of responses? Would be good to mention that
> in

It is called for all valid final HTTP response messages (status code =>
200).

> https://hc.apache.org/httpcomponents-client-5.2.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.html
>  and other mentions of the execute method leveraging the parameter
> FutureCallback (because it seems to be specific to the FutureCallback
> being used from HttpAsyncClient.execute(…))
> 
> 2) What (unchecked) exception to throw in the FutureCallback method
> for the future to fail with ExecutionException.html. Does it matter?
> Is there any recommendation, e.g. if the HTTP endpoint returned a 500
> status? Maybe also the examples e.g. in
> https://github.com/apache/httpcomponents-client/blob/5.2.x/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
>  could be extended in this regard.
> 

You should consider returning a object with error information as a
result of the operation instead of throwing an unchecked exception from
the callback. 

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to