PHP连接:关闭 [英] PHP Connection: Close

查看:140
本文介绍了PHP连接:关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP应用程序,我一直有一些问题,一些页面需要很长的时间加载。



几个小时后,我想到了



问题似乎是用标题 Connection:keep-alive code>。我使用了一个名为Tamper Data的Firefox插件,它允许你篡改标题和内容。一旦我使用该工具将连接标题更改为连接:关闭停止某些网页上的延迟。



在PHP中,我可以确保使用 Connection:close 头吗?



c $ c>头(连接:关闭); 在PHP文件的顶部,并重新加载页面。它仍然发送 Connection:keep-alive 头,而不是我想发送的。



如何我实现了我想要做什么?



编辑:我刚刚意识到,在这个子域内容长度头不发送所有的大多数页面。



$ b

编辑2: b

这是此页: http:// volunteer .essentialtransit.com / job / 13 / just-a-test-at-eta /



点击立即应用链接,填写一些随机txt,您不需要附加文件。注意,当您重定向回作业详细页面时,需要很长时间才能加载。

解决方案

,我确定了问题是什么,并找到了解决这个问题的办法。



处理表单的脚本只处理输入并重定向到另一个页面,它实际上没有输出任何东西。在网站上的大多数页面上,content-length标头未发送,或设置为正确的值。但由于某些原因,当发布到一个页面,然后重定向没有处理脚本输出任何东西到浏览器,内容长度设置为0.



我试过设置内容长度自己,但没有多少运气,因为它似乎没有改变。



所以,我做的是做处理脚本有一些输出。所以现在当表单被提交时,处理脚本输出一个带有重定向脚本的页面(和一个点击继续消息,以防万一),导致正确的页面。因此,虽然这增加了表单提交和正在查看的正确页面之间的一个非常短暂的延迟,它会导致正确设置内容长度,并解决问题。



While这不是一个理想的解决方案,它是可管理的,并使脚本工作。


I have a PHP application that I have been having some problems with, some pages take a very long time to load.

After a couple of hours I have figured out the problem, but I have no idea how to fix it.

The problem seems to be with the header Connection: keep-alive. I used a Firefox plugin called "Tamper Data" which allows you to "tamper" with the headers and stuff. Once I used that tool to change the connection header to Connection: close the delay on some pages stopped.

How, in PHP, can I make sure that the Connection: close header is used?

I tried putting header("Connection: close"); at the top of a PHP file, and reloaded the page. It still sends the Connection: keep-alive header, not the one I am trying to send.

How can I achieve what I am trying to do?

EDIT: I have just realized that on this subdomain the content-length header is not sent at all for most pages. It is only sent right after a form submission followed by a redirect.

EDIT 2:

This is the page: http://volunteer.essentialtransit.com/job/13/just-a-test-at-eta/

Click the "Apply now" link and fill out some random txt, you don't need to attach a file. Notice when you are redirected back to the "job" detail page that it will take a very long time to load.

解决方案

So, I determined what the problem was, and found a work-around to this issue.

The script that processed the form just processed the input and redirected to another page, but it actually didn't output anything. On most pages on the site the content-length header is either not sent, or is set at the correct value. But for some reason when posting to a page, and then redirecting without the processing script outputting anything to the browser, the content-length was being set at 0.

I tried setting the content-length myself, but didn't have much luck, as it didn't seem to make a difference.

So, all I did was make the processing script have some output. So now when the form is submitted the processing script outputs a page with a redirect script (and a 'click to continue' message just in case) that leads to the correct page. So while this adds a very brief delay between the form submission and the correct page being seen it causes the content-length to be set correctly and the problem is solved.

While this is not an ideal solution it is manageable and makes the script work.

这篇关于PHP连接:关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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