httpbin icon indicating copy to clipboard operation
httpbin copied to clipboard

Feature request: "chunked" header in /drip

Open Lucretiel opened this issue 7 years ago • 7 comments

It'd be nice if the /drip endpoint accepted an additional header, called chunked, which (if given as true) would make it so that /drip doesn't use a content-length, and instead uses chunked encoding. This would be nice for testing clients that are designed to consume "live" data.

Lucretiel avatar Jun 29 '18 02:06 Lucretiel

If there's support for this I can put together a pull request

Lucretiel avatar Jun 29 '18 02:06 Lucretiel

Just checking that neither /range or /stream-bytes fill that need.

javabrett avatar Jun 29 '18 11:06 javabrett

The specific thing I'm trying to test is early termination— that is, cancelling a request that is in the middle of streaming a body. For that reason, it would be very helpful to have a request that streams over a duration, so that I can easily initiate termination halfway through it.

Lucretiel avatar Jun 29 '18 14:06 Lucretiel

They're both close, but not quite there. /range supports a duration parameter, but doesn't use the chunked transfer encoding. /stream-bytes does do chunked encoding, but doesn't have a tuneable duration.

Lucretiel avatar Jun 29 '18 19:06 Lucretiel

A note for those still looking for such endpoint - /stream-bytes has an undocumented parameter chunk_size that can be helpful. By default it is 10k, making the endpoint appear non-streaming for smaller responses. The max response length it can return is 100k, making for just 10 chunks with the default chunk_size.

A chunk_size of 1 makes the endpoint considerably slow - around 1k/s, so it seems it could be useful for cases like what Lucretiel needed.

Also, from testing it seems even if you request a chunk_size of 1, you get quite a larger chunk size. I base this conclusion on the "transfer-size" field in browser dev tools - it should be 6 times higher than the content size if each chunk were a single byte, but it's barely higher in practice. My guess is that the reverse proxy ("vegur") in front of httpbin.org re-chunks the response.

georgir avatar Aug 15 '18 15:08 georgir

I was very disappointed to discover that drip doesn't support chunked responses. That endpoint seems like you'd want chunked responses by default. So make me a +1 for wishing it supported chunked responses!

dswitzer avatar Jan 11 '24 12:01 dswitzer

@dswitzer and others looking at this in the future i don't remember how things worked back in 2018 anymore, but now httpbin.org's servers use http/2 protocol where there is no such thing as explicit transfer-encoding: chunked header, and instead its functionality is supported by default. /drip endpoint works fine with it when i test. i would say this issue can be closed demo

anonghuser avatar May 17 '24 23:05 anonghuser