如何提供有关异步请求完成的信息

如何提供有关异步请求完成的信息

本文介绍了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?

来自(斜体字由我添加):

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

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.

以下是一些想法:


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

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

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

  • 添加(非 X - )特定响应标头?如果是这样,它应该如何命名?问题给出了一些想法,但在弃用之后它只回答了如何格式化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:

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

08-27 07:44