On Fri, 2018-02-16 at 13:01 +0000, COURTAULT Francois wrote:
> Hello everyone,
> 
> I want to use HttpServer for testing purpose.
> The way I want to use, it is:
> 
> *       Start the Httpserver with a HttpRequestHandler registered for
> a dedicated URI
> 
> *         Receive POST requests on this URI  with a payload
> 
> *         Check the payload
> 
> o   If the payload doesn't contain a dedicated id, continue to
> receive POST requests until a certain  duration is reached.
> 
> o   If the payload contains the dedicated id but with additional
> data  that doesn't match what we are waiting for, return a 400  and
> then stop/shutdown the HttpServer right after.
> 
> o   If the payload contains the dedicated id  with additional data
> that matches what we are waiting for, return 200 and then
> stop/shutdown the HttpServer right after.
> 
> 
> I have found a way to do this, using some flags, but I have to wait
> for a timeout using awaitTermination method.
> 
> 
> Is there a way, once I have received either a POST request with a
> right payload or a wrong payload, in the HttpRequestHandler.handle
> method, to return an HTTP response and, right after perform
> a  stop/shutdown of the HttpServer ?
> 

One should be able to do so by throwing an unchecked (runtime)
exception but why would you want to shut down the server from a request
handler in the first place? Would not it be massively cleaner and
easier to just a return a proper response and let the caller decide
whether or not the server should be shut down?

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