本文介绍了响应中的状态码重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常在Tomcat服务器中部署Java Web应用程序,并使用proxy_ajp通过Apache代理访问它们。问题是,在我的最新设置(基本上都相同)中,我发现在所有请求中得到的状态代码都是重复的(即状态代码:200 200)。我可以在每个浏览器,Postman中获得它,对于任何状态代码我都可以得到,一切似乎都可以正常工作,但是我担心我的设置可能不是最佳的。

I usually deploy Java webapps in Tomcat servers and access them through an Apache proxy, using proxy_ajp. The thing is, in my latests setups (which are all basically the same) I see that the status code I get in all my requests is duplicated (i.e., "Status Code:200 200"). I get this in every browser, in Postman, and for any status code I might get, and everything seems to work fine, but I'm concerned my setup might not be optimal.

尽管找不到解决方案,但已将问题范围缩小到ajp_proxy,就好像我更改了

Although I can't find a solution, I have narrowed the issue down to the ajp_proxy, as if I change

ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/

with:

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

我收到的录入通知只有一个状态码。

I get just a single status code for my requets, as expected.

我已经搜索了此问题,但还没有发现与之相关的任何内容,因此,非常感谢您提供任何信息。

I have searched for this issue and I haven't found anything even marginally related to it, so any information would be very much appreciated.

服务器信息:


  • Apache版本:Apache / 2.4.18(Ubuntu )

  • Tomcat版本:apache-tomcat-8.5.13

请先感谢。

推荐答案

Tomcat 8.5从响应中删除了 HTTP状态原因短语,因此您将获得 HTTP 200 而不是响应中的 HTTP 200 OK 。您的观察结果可能来自将状态代码复制到状态原因短语中进行显示的软件。

Tomcat 8.5 removed the "HTTP status reason phrase" from the response, so you'll get HTTP 200 instead of HTTP 200 OK in the response. It's possible that your observations are from software that duplicates the status code into the status reason phrase for display.

您如何观察状态码?您可能会发现,如果执行协议跟踪,将会看到Tomcat / httpd仅发送一个状态代码。

How are you observing the status code? You may find that if you do a protocol trace, you'll see that there is only a single status code being sent by Tomcat / httpd.

这篇关于响应中的状态码重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:48
查看更多