I need partial range requests, because I will transcode in real time, I can not completely transcode the file and get it on demand.
For an answer that you do not know yet, the full body content (you cannot guess the Content-Length , live encoding), use the chunk encoding:
HTTP/1.1 200 OK Content-Type: video/mp4 Transfer-Encoding: chunked Trailer: Expires 1E; 1st chunk ...binary....data...chunk1..my 24; 2nd chunk video..binary....data....chunk2..con 22; 3rd chunk tent...binary....data....chunk3..a 2A; 4th chunk nd...binary......data......chunk4...etc... 0 Expires: Wed, 21 Oct 2015 07:28:00 GMT
Each piece is sent when it is available: when several frames are encoded or when the output buffer is full, 100kB, etc. are generated.
22; 3rd chunk tent...binary....data....chunk3..a
Where 22 indicate the length of the byte of the block in hex (0x22 = 34 bytes),; ; 3rd chunk - additional information about the object (optional), and tent...binary....data....chunk3..a - the contents of the fragment.
Then, when the encoding is complete and all the pieces are sent, complete with:
0 Expires: Wed, 21 Oct 2015 07:28:00 GMT
Where 0 means that no more pieces are followed by zero or more trailers (allowed header fields) defined in the header ( Trailer: Expires and Expires: Wed, 21 Oct 2015 07:28:00 GMT not required) to provide checksums or digital signatures, etc.
Here is the equivalent of a server response if the file is already generated (no live encoding):
HTTP/1.1 200 OK Content-Type: video/mp4 Content-Length: 142 Expires: Wed, 21 Oct 2015 07:28:00 GMT ...binary....data...chunk1..myvideo..binary....data....chunk2..content...binary....data....chunk3..and...binary......data......chunk4...etc...
For more information: Chunked transfer encoding - Wikipedia , Trailer - HTTP | MDN