I have a new question on the same topic so I'll continue here.
When my http server receives a file request from the browser it sends the entire file(36mb). Send() returns a receipt with a result equal to the entire file length + headers length.
However, webtools show that only 171 B has been received and everything is OK / 206 partial. What happened to the rest? Is the entire file (36mb) sent to the browser/recipient and then only 171 B is read into the browser?
The browser continues to send requests, the server receives a second request for a new range that should already have been sent and received the first time. Webtools shows that 176 B is received for this one.
I understand that the entire video is not necessary in the beginning before the user has pressed play, but why not take what is needed when it receives the first response instead of creating 2-3 recurring identical requests? I have been thinking a lot about this behavior and really hope someone has time to give me a little better insight into what is happening?
Request 1:
GET /file.mp4 HTTP/1.1
Host: localhost:27015
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Accept: */*
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: no-cors
Referer:
http://localhost:27015/index.php
Accept-Language: sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: _ga=GA1.1.335564697.1576867333
Range: bytes=0-
Response:
HTTP/1.1 206 Partial Content
Accept-Ranges: bytes
Connection: keep-alive
Content-Type: video/mp4
Content-Range: bytes 0-38722853/38722854
Content-Length: 38722854
(body)
Request 2:
GET /file.mp4 HTTP/1.1
Host: localhost:27015
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Accept: */*
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: no-cors
Referer:
http://localhost:27015/index.php
Accept-Language: sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: _ga=GA1.1.335564697.1576867333
Range: bytes=262144-
Response:
HTTP/1.1 206 Partial Content
Content-Range: bytes 262144-38722853/38722854
Content-Length: 38722854
Accept-Ranges: bytes
Connection: keep-alive
Content-Type: video/mp4
(body)