紧急:阻止发送默认HTTP标头 [英] URGENT: Prevent default HTTP headers from being sent
问题描述
我有一个不超过这个的PHP脚本:
<?php echo" Hello World!英寸; ?>
当webbrowser客户端请求数据时,它接收Apache服务器头,
后跟我的数据:
HTTP / 1.1 200 OK
日期:2005年6月28日星期二06:02:56 GMT
服务器:Apache / 1.3.27(Unix)(红色 - Hat / Linux)mod_ssl / 2.8.12 OpenSSL / 0.9.6b
DAV / 1.0.2 PHP / 4.1.2 mod_perl / 1.26
X-Powered-By:PHP /4.1.2
连接:关闭
转移编码:分块
内容类型:text / html
c
Hello World!
0
============= ==========
问题:
- 'c'和'0'来自哪里? 0只是表示数据的结尾?
- 如何防止发送回客户端的HTTP标头?我希望只发送
Hello World!,没有任何标题。原因是客户端将是一块需要二进制数据作为响应的硬件,而不是HTTP头。
我不认为这可以用PHP,因为它可能由
apache处理。
如果是这样的话,我可以使用Apache的RewriteEngine来完成这个,以防万一
User-Agent是^ MyThinHardware。*。 ?
如何防止Apache发送这些标题?
=======================
我使用以下php脚本模拟客户端请求php页面,
并显示标题:
$ header =" POST $ cgi HTTP / 1.1\r\\\
" ;;
$ header。=" Host:$ host\r\\\
" ;;
$ header。=" User-Agent:MyThinHardware / 1.0\r\ n" ;;
$ header。=" Content-Type:application / octet-stream \\ \ \ n" ;;
$ header。=" Content-Length:$ size\r\ n" ;;
$ header。=" Connection :close\r\\\
" ;;
$ header。=" \\\\ nn" ;;
/ *发布数据* /
$ fp = fsockopen($ host,80,$ errno,$ errstr,30);
if(!$ fp){
die(") $ errstr($ errno)");
}
else {
fwrite($ fp,$ header);
fwrite($ fp,$ data,$ size);
while(!fe ($ fp)){
$ response。= fgets($ fp,128);
}
fclose($ fp);
}
echo $ response;
header =" POST
cgi HTTP / 1.1\r\\\
" ;;
header。=" Host:
Hi,
I have a php script with no more than this:
<?php echo "Hello World!"; ?>
When a webbrowser client requests data, it receives Apache server headers,
followed by my data:
HTTP/1.1 200 OK
Date: Tue, 28 Jun 2005 06:02:56 GMT
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6b
DAV/1.0.2 PHP/4.1.2 mod_perl/1.26
X-Powered-By: PHP/4.1.2
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
c
Hello World!
0
=======================
QUESTIONS:
- Where do the ''c'' and ''0'' come from? ''0'' just denoting the end of the data?
- How do I prevent HTTP headers sent back to the client? I wish to only send
"Hello World!", without any headers. The reason is that the client will be a
piece of hardware that expects binary data as response, not HTTP headers.
I don''t think this can be done with PHP, as it is probably handled by
apache.
If so, can I use Apache''s RewriteEngine to accomplish this, in case
User-Agent is "^MyThinHardware.*" ?
How can I keep Apache from sending these headers?
=======================
I use the following php script to simulate a client requesting the php page,
and display the headers:
$header = "POST $cgi HTTP/1.1\r\n";
$header .= "Host: $host\r\n";
$header .= "User-Agent: MyThinHardware/1.0\r\n";
$header .= "Content-Type: application/octet-stream\r\n";
$header .= "Content-Length: $size\r\n";
$header .= "Connection: close\r\n";
$header .= "\r\n";
/* post data */
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
die("$errstr ($errno)");
}
else {
fwrite($fp, $header);
fwrite($fp, $data, $size);
while (!feof($fp)) {
$response .= fgets($fp, 128);
}
fclose($fp);
}
echo $response;
header = "POST
cgi HTTP/1.1\r\n";
header .= "Host:
这篇关于紧急:阻止发送默认HTTP标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!