Why most API paginations do not rely on HTTP Range header?

时间秒杀一切 提交于 2019-12-04 02:16:34
ludofleury

Here the answers that I gently borrowed from this question thanks to @ptidel: Content-Range header - allowed units?.

First, custom units are proposed in this draft HTTP/1.1, part 5: Range Requests and Partial Responses

Second, there is a subtle difference, the first statement has been made for parsing purpose

    range-unit       = bytes-unit | other-range-unit
    bytes-unit       = "bytes"
    other-range-unit = token

While the second statement has been made for producing HTTP request.

Finally, the whole comment from Ferenc Mihaly summarizes perfectly the situation:

I conform to the HTTP spec when I'm sending [a custom range unit] and they conform to HTTP when they ignore it

WebDAV uses HTTP extensions correctly, IMO, but rarely works over the Internet for exactly this reason

Most of the times you don't want to show all of your items by default. With ?p=2 style pages it's ok to reserve root / for first page. With "Range" header it would be strange behavior. HTTP became overbloated long time ago so I wouldn't recommend to accept every its headers as Truth.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!