HTTP状态202 - 如何提供有关异步请求完成的信息? [英] HTTP Status 202 - how to provide information about async request completion?

查看:2897
本文介绍了HTTP状态202 - 如何提供有关异步请求完成的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当服务器返回异步请求的 202 - Accepted 状态代码时,对请求完成情况给出估计的适当方法是什么?

What is the appropriate way of giving an estimate for request completion when the server returns a 202 - Accepted status code for asynchronous requests?

来自 HTTP规范斜体字由我添加):


202已接受

该请求已被接受处理,但处理尚未完成。 [...]

The request has been accepted for processing, but the processing has not been completed. [...]

使用此响应返回的实体应该包括请求当前状态的指示以及指向状态监视器的指针或某些估计值当用户可以期望完成请求时

The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.

以下是一些想法:


  • 我瞥了一眼 max-age 指令,但使用它会滥用 Cache-Control

  • 返回响应正文中的预期等待时间?

  • 添加特定于应用程序的 X - 响应标头,但 x - 标题已在 RFC 6648 中弃用?

  • 添加(非 X - )特定响应标头?如果是这样,它应该如何命名?问题自定义HTTP标头:命名约定给出了一些想法,但在弃用之后它只回答了如何格式化HTTP标头,而不是如何命名。

  • 其他建议?

  • I have glanced at the max-age directive, but using it would be abusing Cache-Control?
  • Return the expected wait time in the response body?
  • Add an application specific X- response header, but the X-headers was deprecated in RFC 6648?
  • Add a (non X-) specific response header? If so, how should it be named? The SO question Custom HTTP headers : naming conventions gave some ideas, but after the deprecation it only answers how HTTP headers are formatted, not how they should be named.
  • Other suggestions?

推荐答案

虽然没有明确提及 202 - 接受响应代码,但 Retry-After 标题似乎是一个合适的选择。来自文档

Although not explicitly mentioned specifically for the 202 - Accepted response code, the Retry-After header seems to be a suitable option. From the documentation:


可以使用Retry-After响应头字段来指示服务预计对请求客户端不可用的时间。

The Retry-After response-header field can be used [...] to indicate how long the service is expected to be unavailable to the requesting client.

这篇关于HTTP状态202 - 如何提供有关异步请求完成的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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