So, I'm using Http4k streaming like so ```val clie...
# http4k
q
So, I'm using Http4k streaming like so
Copy code
val client = ApacheClient(responseBodyMode = BodyMode.Stream, client = HttpClients.custom()
		.setDefaultRequestConfig(RequestConfig.custom()
				.setCookieSpec(CookieSpecs.IGNORE_COOKIES)
				.build()).build())

val app = { request: Request ->
	val query = Request(Method.GET, "<some url>")
	val response = client(query)

	Response(Status.OK).body(response.body)
}.asServer(Netty(port)).start()
Now if I use Jetty, the streaming nature works fine. I want to use Netty however, and switching to Netty means all the streaming code is ignored, and no waterfall occurs.
s
Had a look at the Netty integration code it looks like it doesn’t support streaming (it copies using a ByteBufOutputStream) :(
We could encode in the API whether streaming is supported for each backend (ie it fails to start a server in streaming mode if it doesn’t support).
Regardless, if you know how Netty does streaming and would like to propose a change, I’m happy to look at it.
q
Oh the surface of that API is really minimal. I'll see what I can do.
🙂 1
I expected a lot more Netty specific code.
@s4nchez I took a try at this, and got something to work for streaming the response. https://gist.github.com/carbotaniuman/fc0e6baf4048cf17a3ca12239b75fba9
It appears that http4k doesn't support streaming request bodies, so no harm done?
s
It does support steaming for both request and response but it depends on the specific client/servers you choose
And yes, the integrations are all very small. To the point we suggest people to copy and adjust to their own needs if they are very specific.
We’d be happy to try and integrate your changes if you submit a PR for it, too.
q
Also, it appears that specifiying a length in Response#body doesn't propogate it to the headers field?
s
I've merged you PR and added the streaming contract testing. Some servers tend to control
content-lengh
header themselves, so it could be the case of what's happening there....
Please let me know if you need your change urgently, otherwise it'll come out in the next release 🙂