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

查看:358
本文介绍了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天全站免登陆