问题描述
我正在尝试测试服务器,以查看其是否符合以下定义,为此,我需要从上游服务器构造无效的响应并将其发送到网关服务器. HTTP规范对状态码502-错误的网关进行了以下说明.
I'm trying to test a server to see if it behaves according to the definition below and for that, I need to construct and send an invalid response to the gateway server, from the upstream server. The HTTP spec says the following regarding the status code 502 - Bad Gateway.
但是什么才是无效响应呢?非标准响应代码(例如,一些随机数,例如6789)是否算作无效响应?还是HTTP版本无效的响应?
But what exactly constitute an invalid response? Does a non-standard response code (say, some random number like 6789) count as an invalid response? Or a response with an invalid HTTP version?
请输入以下内容: 502 HTTP状态代码,其中指出不完整的标头和响应主体可以导致502错误.服务器如何确定标头或正文不完整?更重要的是,是否可以通过编程方式创建这样的响应(我正在使用Java)?
Came across this: 502 HTTP Status Code, which says incomplete headers and response bodies can cause 502 errors. How does a server determine if the headers or the body is incomplete? And more importantly, is it possible to create such a response programmatically (I'm using Java)?
推荐答案
我设法在HTTP规范(RFC7230第3.3.3节)中找到了以下内容.
I managed to find the following in the HTTP spec (RFC7230 section 3.3.3).
除此之外,我还注意到,当上游服务器关闭时,Nginx在充当反向代理/负载平衡器时返回502.
Apart from this, I've also noticed that Nginx returns a 502 when acting as a reverse proxy/load balancer, when the upstream server is down.
这篇关于在HTTP 502中,无效响应是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!