问题描述
我有一个移动设备通过HTTPS与我服务器上的RESTful API进行通信。其中一项操作是数据同步,用于将离线时进行的修改推送到服务器,并下拉服务器上并行进行的更新。
我遇到过边缘情况在现有客户端中,同步操作可能会以静默方式失败。我已经升级了客户端上的同步协议以正确处理条件。理想情况下,我希望让所有旧客户端在尝试同步时告知他们升级时收到消息。
通信就在我的服务器和移动客户端之间,所以我意识到我可以返回任意数量的HTTP代码并通知客户端将来显示一条消息,建议用户升级并立即停止同步过程。
它被视为HTTP 426升级所需返回代码的意图的混蛋,以使用它来发出信号。每个参考文献(,)我可以找到使用它来表示客户端升级到TLS的说法。它是否仅限于SSL和TLS等定义明确的安全协议,还是HTTP层的通用升级标志,传统上仅用于SSL和TLS?
如果不是针对此用例,那么HTTP 303 See Other会被认为是更合适还是还有其他代码我不知道?
引用我的:
(此后IANA注册没有变更。)
中定义的426响应代码显然与升级有关。 HTTP升级感知在RFC 2816中定义。这是对当前 pr的更改在目前使用的层上的协议(即HTTP本身)。 (它甚至不是从 http://
升级到 https://
。
在HTTP之上交换的消息(如果是协议的一部分)不属于此类。就HTTP而言,它们只是超媒体实体。
如果你改变超媒体的含义,我认为426不合适。平原400可能是更好的选择。请注意,具有错误状态代码(4xx,5xx)的响应不会阻止您在响应中关联实体:这是告知客户端升级协议(在该级别)的消息应该是。
I have a mobile device communicating via HTTPS to a RESTful API on my servers. One of the operations is a data sync to push modifications made while offline to the server and pull down updates made in parallel on the server.
I've encountered an edge case where that sync operation can fail silently in the existing client. I've upgraded the "sync protocol" on the client to handle the condition properly. Ideally I'd like to have all older clients receive a message when they try to sync telling them to upgrade.
The communication is just between my server and my mobile client so I realize I can return any number of HTTP codes and signal the client to display a message in the future advising the user to upgrade and to immediately stop the sync process.
Would it be seen as a bastardization of the intent of the HTTP 426 Upgrade Required return code to use it to signal this. Every reference (IETF RFC 2817, Wikipedia) I can find speaks to using it to signal a client to upgrade to TLS. Is it meant to be limited to well defined/security protocols like SSL and TLS or is it a generic upgrade flag at the HTTP layer which has only been used for SSL and TLS traditionally?
If it isn't intended for this use case would a HTTP 303 See Other be considered more appropriate or is there another code I'm missing?
Quoting one of my previous answers:
(The IANA register hasn't changed since then.)
The 426 response code as defined in RFC 2817 clearly has to do with an upgrade in the "HTTP Upgrade" sense defined in RFC 2816. This is a change of the current protocol at the layer currently used (i.e. HTTP itself). (It's not even about upgrading from http://
to https://
at all.)
The messages exchanged on top of HTTP (if part of a protocol at all) are not part of this. They're just hypermedia entities as far as HTTP is concerned.
I don't think 426 would be suitable if you change the meaning of your hypermedia. A plain 400 would probably be a better choice. Note that responses with error status codes (4xx, 5xx) do not prevent you from associating an entity in the response: this is where a message telling the client to upgrade your protocol (at that level) should be.
这篇关于HTTP状态代码426升级是否仅表示需要升级到安全通道的信号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!