HTTP请求返回状态码0是什么意思?

编程入门 行业动态 更新时间:2024-10-21 06:45:58
本文介绍了HTTP请求返回状态码0是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当JavaScript网络调用(例如fetch或XMLHttpRequest或任何其他类型的HTTP网络请求)失败且HTTP状态代码为0时,这是什么意思?

What does it mean when JavaScript network calls such as fetch or XMLHttpRequest, or any other type of HTTP network request, fail with an HTTP status code of 0?

这似乎不是有效的HTTP状态代码,因为其他代码是HTTP规范中的三位数字。

This doesn't seem to be a valid HTTP status code as other codes are three digits in HTTP specification.

作为测试,我试图完全拔掉网络。它可能不相关,但是导致状态代码17003(IIRC),粗略搜索表明状态代码 DNS服务器查找失败。

I tried unplugging the network completely as a test. It may be unrelated, but that resulted in status code 17003 (IIRC), which cursory searching suggests means "DNS server lookup failed".

相同的代码在某些情况下也能正常工作位置和系统,但是在某些环境中会失败,状态码为0,并且没有提供responseText。

The same code works fine from some locations and systems, however within certain environments it fails with status code 0 and there is no responseText provided.

这是到Internet URL的典型HTTP POST。它不涉及file://,据我所知可能会返回0,表示在Firefox中成功。

This is a typical HTTP POST to an Internet URL. It does not involve file:// which I understand may return 0 indicating success in Firefox.

推荐答案

我相信错误代码表明响应为空(甚至没有返回标头)。这表示已接受连接,然后正常关闭(TCP FIN)。 可能导致此问题的原因有很多,但是根据您的描述,某种形式的防火墙似乎是最有可能的罪魁祸首。

I believe the error code indicates that the response was empty, (as not even headers were returned). This means the connection was accepted and then closed gracefully (TCP FIN). There are a number of things which could cause this, but based off of your description, some form of firewall seems the most likely culprit.

更多推荐

HTTP请求返回状态码0是什么意思?

本文发布于:2023-11-17 12:14:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609966.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!