C5T / Current

C++ framework for realtime machine learning.
https://medium.com/dima-korolev/current-for-realtime-machine-learning-4f04aa8ab81a
97 stars 29 forks source link

Fixes for Docker API #884

Closed dkorolev closed 2 years ago

dkorolev commented 3 years ago

Hi @mzhurovich -- this is my poor attempt to make it possible for the "user space" code to declare the HTTP response a chunked one based on the headers seen so far.

dkorolev commented 3 years ago

@mzhurovich -- okay, this proved to be more complicated.

I ended up adding (partial) support for "upgraded" connections, which effectively are a "light", binary version of the chunked ones: just read from the socket, in binary format, until forever from the point where the (potentially binary) body begins.

This can be triggered with Connection: upgrade, or with Upgrade: <anything> headers, or via a per-header callback which would call response_kind.MarkAsUpgraded(), so that the user can employ their own, custom logic.

Yes, this is a hack. Yes, I've tested it, including with a delay, to ensure the body is indeed streamed.

No, I don't quite see a usecase for this except making the Docker "HTTP" API work ;-)

Thanks for understanding! Dima

dkorolev commented 2 years ago

Ok, I'll close this PR. Will leave the fixes_for_docker_api branch here, just in case we do need these changes in the future.

CC @mzhurovich