HTTP请求返回状态码0是什么意思? [英] What does it mean when an HTTP request returns status code 0?

查看:7503
本文介绍了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是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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