users@grizzly.java.net

Issue creating simple blocking http client.

From: Daniel Feist <dfeist_at_gmail.com>
Date: Fri, 3 Oct 2014 00:43:46 +0100

Hi,

While I have successfully been using grizzly for a few day server-side,
i've run into an issue attempting to build a simple http client that sends
a body using POST and then receives a body in return from the server.

I've been able to put together a filter chain with a custom Filter that
will send "Hello World" and receive and print the response easily enough,
But I can't work out how to use this from within a blocking method with a
signature of type "Response execute(Request req)" without creating a new
filterChain each time and giving it an filter using an inner class with
access to the request payload and able to write the response somewhere
where it can be used as a return value of the method.

I write using connection.write() and connction.read(), but while the
write() is fine, the read doesn't produce any result because the response
by this type has already been processed in another thread (via a selector
registered on the channel with 'READ' interest i presume)

(BTW I'm attempting to use this with a connection-pool.)

Should I be creating a new filterChain for each request (is this even
possible when using connection pool) or there something much more obvious
that I'm missing?

thanks,

Dan