当php与g-wan一起使用时,如何设置http响应头 [英] How to set http response header when php is used with g-wan

查看:114
本文介绍了当php与g-wan一起使用时,如何设置http响应头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在hello.php示例中添加了header函数,如下所示:

I add the header function in the hello.php sample, as below:

<?php
   header("xxxxx: yyyyy");
   fwrite(STDOUT, "see headers.<br><br>Hello, PHP!<br>current working directory: ".getcwd());
   exit(200); // return an HTTP code (200:'OK')
?>

但是在firebug中没有找到这样的标题。

谁可以解释如何用gwan在php cli中添加额外的标题?

but there is no such header found in firebug.
Who can explain how to add additional headers in php cli with gwan?

推荐答案

感谢Gil和Richard,

现在,这是我根据你的建议做的。 PHP在gwan中使用自定义标题。

Thanks to Gil and Richard,
Now, it is what i did according to your advices. PHP works in gwan with customized headers.

<?php
 $output='See headers....Hello, PHP!<br>from gwan';
   $len=strlen($output);
   fwrite(STDOUT, "HTTP/1.0\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: close\r\nContent-Length: $len\r\nxxxxx: yyyyy\r\n\r\n$output");
    exit(1);
?>

我使用 ab -c 1000 -n 100000 http:127.0.0.1/ ?hello.php

内存使用率增加 2.9GiB = 0.0203GiB的0.7%

CPU使用率是从 20%增加到75%= 50%(ab在同一台机器上运行gwan)

我在旧机器上运行了intel P9300 2.26GHz x 2,ubuntu 12.04

i use ab -c 1000 -n 100000 http:127.0.0.1/?hello.php
The memory usage is increased by 0.7% of 2.9GiB = 0.0203GiB
The CPU usage is increased from 20% to 75% = 50% (ab run in the same machine with gwan)
I did it in my old machine intel P9300 2.26GHz x 2, ubuntu 12.04

它以9.543秒结束而没有失败

10,479 req / sec

it finished in 9.543 sec without failure
about 10,479 req/sec

这篇关于当php与g-wan一起使用时,如何设置http响应头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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