gpt4 book ai didi

javascript - 在 XMLHttpRequest 中接收 102 http 状态

转载 作者:可可西里 更新时间:2023-11-01 17:16:44 26 4
gpt4 key购买 nike

自 v10 起,Node.js 支持发送 102 Processing 状态码,但我不确定如何使用它。

它是浏览器仅在内部使用的东西(比如它延迟超时事件)还是我们可以通过任何方式访问这个临时状态?

我想让我的 javascript 代码知道“嘿,我正在处理这个,请稍等”。发送临时状态似乎是最简单的出路。

另一种选择是使用 202 状态,但这需要进行更多更改。

最佳答案

你是对的。

102 PROCESSING

An interim response used to inform the client that the server has accepted the complete request, but has not yet completed it.

This status code SHOULD only be sent when the server has a reasonable expectation that the request will take significant time to complete. As guidance, if a method is taking longer than 20 seconds (a reasonable, but arbitrary value) to process the server SHOULD return a 102 (Processing) response. The server MUST send a final response after the request has been completed.

Methods can potentially take a long period of time to process, especially methods that support the Depth header. In such cases the client may time-out the connection while waiting for a response. To prevent this the server may return a 102 Processing status code to indicate to the client that the server is still processing the method.

你可以在https://httpstatuses.com/102看到它或 https://www.rfc-editor.org/rfc/rfc2518#section-10.1

关于javascript - 在 XMLHttpRequest 中接收 102 http 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57054222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com