-
HTTP Range Request개발/Web 2022. 6. 14. 23:09
*복습 자료라서 뻔한 내용은 생략
Summary.
1. An HTTP range request asks the server to send only a portion of an HTTP message back to a client. Range requests are useful for clients like media players that support random access, data tools that know they need only part of a large file, and download managers that let the user pause and resume the download
+ If an HTTP response includes the Accept-Ranges header and its value is anything other than "none", then the server supports range requests. You can perform a manual check by issuing a HEAD request with a tool like cURL
curl -I http://i.imgur.com/z4d4kWk.jpg HTTP/1.1 200 OK ... Accept-Ranges: bytes Content-Length: 146515
curl -I https://www.youtube.com/watch?v=EwTZ2xpQwpA HTTP/1.1 200 OK ... Accept-Ranges: none
2. If the server supports range requests, then by including the Range header in your HTTP request, you can specify which part or parts of the document you want the server to return
GET /z4d4kWk.jpg HTTP/1.1 Host: i.imgur.com Range: bytes=0-1023
HTTP/1.1 206 Partial Content Content-Range: bytes 0-1023/146515 Content-Length: 1024 ... (binary content)
curl http://www.example.com -i -H "Range: bytes=0-50, 100-150"
HTTP/1.1 206 Partial Content Content-Type: multipart/byteranges; boundary=3d6b6a416f9b5 Content-Length: 282 --3d6b6a416f9b5 Content-Type: text/html Content-Range: bytes 0-50/1270 <!doctype html> <html> <head> <title>Example Do --3d6b6a416f9b5 Content-Type: text/html Content-Range: bytes 100-150/1270 eta http-equiv="Content-type" content="text/html; c --3d6b6a416f9b5--
3. The If-Range HTTP request header makes a range request conditional: if the condition is fulfilled, the range request will be issued and the server sends back a 206 Partial Content answer with the appropriate body. If the condition is not fulfilled, the full resource is sent back, with a 200 OK status. This header can be used either with a Last-Modified validator, or with an ETag, but not with both
If-Range: Wed, 21 Oct 2015 07:28:00 GMT
4. Response Case
- A successful range request elicits a 206 Partial Content status from the server.
- A range request that is out of bounds will result in a 416 Requested Range Not Satisfiable status, meaning that none of the range values overlap the extent of the resource. For example, the first-byte-pos of every range might be greater than the resource length.
- If range requests are not supported, an 200 OK status is sent back and the entire response body is transmitted.
5. The Transfer-Encoding header allows chunked encoding, which is useful when larger amounts of data are sent to the client and the total size of the response is not known until the request has been fully processed. The server sends data to the client straight away without buffering the response or determining the exact length, which leads to improved latency. Range requests and chunking are compatible and can be used with or without each other
Reference.
'개발 > Web' 카테고리의 다른 글
DNS (0) 2022.06.18 Security Context (0) 2022.06.18 HTTP Compression (0) 2022.06.14 HTTP Redirect (0) 2022.06.14 HTTP Caching (0) 2022.06.14