cjstehno / ersatz

🤖 A simulated HTTP server for testing client code with configurable responses.
https://cjstehno.github.io/ersatz
Apache License 2.0
47 stars 5 forks source link

Chunked response support #90

Closed radarsh closed 5 years ago

radarsh commented 6 years ago

Do you intend to provide support for mocking chunked responses similar to how Wiremock does?

cjstehno commented 6 years ago

More information please.

I have multipart response support, if that's what you mean.

If not, please supply a detailed example. The link doesn't tell me anything.

radarsh commented 6 years ago

No, I'm not asking about multipart response support. I'm specifically asking about chunked Transfer Encoding. This is well explained in MDN. In other words, this feature if implemented, would allow for the response to be chunked up and sent in several pieces (stream) rather than one monolithic unit.

Wiremock's withChunkedDribbleDelay allows us to simulate slow network connections by introducing a delay before each chunk is sent out.

Wikipedia also does a good job at explaining this.

cjstehno commented 6 years ago

I'll see what I can do. It may be a few months though as I have other higher priorities right now.

cjstehno commented 5 years ago

This support will be added during the 2.0 re-write. It will be something like:

response {
    conent someBytes, IMAGE_JPG
    chunked {
        chunks 4
        delay 0..10 // or fixed number
    }
}

which will respond with the given data in the specified number of chunks delivered with a given delay between each chunk.

cjstehno commented 5 years ago

Figured out how to make this work with the existing architecture. It will be in 1.8.

cjstehno commented 5 years ago

This has been implemented in 1.8.1 which was released today.