Hidden features of HTTP

前端 未结 13 1084
醉话见心
醉话见心 2021-01-29 17:38

What hidden features of HTTP do you think are worth mentioning?

By hidden features I mean features that already are part of the standard but widely rath

13条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-29 17:45

    You can request to resume a (large) HTTP response (e.g. file download) using Range and If-Range request headers with respectively the specified byte range and the unique file identifier or the file modification timestamp. This is possible if the server has sent the Accept-Ranges: bytes and ETag or Last-Modified response headers on the initial response with respectively the notification that the server supports byte range requests, the unique file identifier and the file modification timestamp.

    The initial response can look like (the ETag is usually composed of file name, size and last modification timestamp):

    Accept-Ranges: bytes
    ETag: file.ext_1234_1234567890
    Content-Range: bytes 0-1233/1234
    

    When the download get aborted on for example 1KB (1024 bytes), the client can resume it as follows:

    If-Range: file.ext_1234_1234567890
    Range: bytes=1024-
    

    Which should return this response with the appropriate bytes in the body:

    Accept-Ranges: bytes
    ETag: file.ext_1234_1234567890
    Content-Range: bytes 1024-1233/1234
    

提交回复
热议问题