[undertow-dev] Undertow http client

Stuart Douglas sdouglas at redhat.com
Mon Dec 15 13:52:03 EST 2014


The Undertow HTTP client was designed to be used in the reverse proxy, not so much as a general purpose HTTP client. 

The only real example of how to use it is at io.undertow.server.handlers.proxy.ProxyHandler, where it is used in the reverse proxy. 

It supports HTTP, AJP, SPDY and the current draft of HTTP2.

It is 100% non-blocking and not thread safe, for the most part interaction with the client should be done in the IO thread of the connection. There has been some talk about adding a blocking/thread safe wrapper at some stage. 

The basic way that it is used is:
- Connect to the remote host
- Create a ClientRequest object and populate it with headers etc
- Call ClientConnection.sendRequest with your request and a callback. When the connection is ready to send your request the callback will be invoked
- If you want a request body use ClientExchange.getRequestChannel() to get a channel to use for sending
- ClientExchange.setResponseListener() is used to register a listener to be notified of a response (you can also set handlers for HTTP 101 continue and server push events)
- Once the response listener has been invoked you can get the client response from the exchange

Stuart

----- Original Message -----
> From: "David Simansky" <dsimansk at redhat.com>
> To: undertow-dev at lists.jboss.org
> Sent: Tuesday, 16 December, 2014 1:32:44 AM
> Subject: [undertow-dev] Undertow http client
> 
> Hi all,
> 
> I have a question regarding Undertow http client. I would like to achieve
> something similar to what jetty http client or apache http clients can do.
> Pretty much just send out http requests with different kind of
> method(+possibly include payload). The question is, if the undertow client
> classes are meant to be used that way because my google search haven't found
> any example of usage like that. Is there any convenient way I could go for?
> 
> Thanks,
> David
> 
> 
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
> 


More information about the undertow-dev mailing list