为什么大多数API分页不依赖于HTTP Range标头? [英] Why most API paginations do not rely on HTTP Range header?

查看:179
本文介绍了为什么大多数API分页不依赖于HTTP Range标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常搜索,但我找不到这个问题的好答案。
作为HATEOAS爱好者,我认为这个标题非常合适:

I've searched a lot but I can't find a good answer to this question. Being a HATEOAS aficionado, I would think that this header fit perfectly:

    Range: item=1-20/100

在HTTP规范中,我不明白一些矛盾:
范围单位可以接受其他范围单位......

In the HTTP spec, I don't understand some "contradictions": The range unit can accept "other-range-unit"...

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

...但规范稍后明确:

... yet the spec is later explicit:


HTTP / 1.1定义的唯一范围单位是字节。 HTTP / 1.1实现可以忽略使用其他单位指定的范围。

The only range unit defined by HTTP/1.1 is "bytes". HTTP/1.1 implementations MAY ignore ranges specified using other units.

最后,规范以此语句结束:

Finally the spec ends with this statement:


HTTP / 1.1旨在允许不依赖于范围知识的应用程序的实现。

HTTP/1.1 has been designed to allow implementations of applications that do not depend on knowledge of ranges.




  • 是否允许除字节之外的任何其他单位?

  • 如果HTTP / 1.1旨在允许app不依赖于范围,那么依赖于API的真正缺点是什么?

  • 注意:我不关心浏览性。

    NB: I don't care about "browsability".

    推荐答案

    由于 @ ptidel 内容范围标题 - 允许的单位?

    首先,本草案中提出了自定义单位 HTTP / 1.1,第5部分:范围请求和部分响应

    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
    

    虽然第二个语句是用于产生HTTP请求的。

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

    最后,来自 Ferenc Mihaly 完美地总结了这种情况:

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


    我符合HTTP规范当我发送[自定义范围单位]并且忽略它时它们符合HTTP

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

    WebDAV正确使用HTTP扩展,IMO,但很少在Internet上工作正是这个原因

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

    这篇关于为什么大多数API分页不依赖于HTTP Range标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆