'How to return HTTP streaming errors? (especially in Rust)

How a streaming (e.g. a sound or video) HTTP server should report failure in the DB from which it streams (when it already streams, 503 header cannot be generated).

The client should be able to differentiate if it received complete file or its beginning only.

I am especially interested how to return such errors in Rust frameworks.



Solution 1:[1]

The HTTP server library you are using should be taking care of this for you.

If you are writing your own server for some reason, you should use the chunked encoding method, which has a clear way to specify that the stream is over (a zero-lengthed chunk).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Colonel Thirty Two