我使用symfony2并创建一个Web服务:
$response = new JsonResponse();
$response->setData(array(
'dt' => time()
));
return $response;
响应有这个标题
HTTP/1.1 200 OK
Date: Tue, 23 Dec 2014 10:23:06 GMT
Server: Apache/2.4.9 (Win64) PHP/5.5.12
X-Powered-By: PHP/5.5.12
Cache-Control: no-cache
X-Debug-Token: 27ccd9
X-Debug-Token-Link: /capteur/web/app_dev.php/_profiler/27ccd9
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json
然而,调用此Web服务的电子设备需要一个较小的标题,如下所示:
HTTP/1.1 200 OK
{"dt":1418812347}
我怎么能用symfony2来完成这个? Symfony总是在标题中添加很多东西......
谢谢!
修改
在生产模式下,某些标头被禁用。 一些.htaccess规则:
<IfModule mod_headers.c>
Header unset X-Powered-By
Header unset Keep-Alive
Header unset Content-Length
Header unset Server
Header unset ETag
Header unset Cache-Control
Header unset Last-Modified
Header unset Date
Header unset Accept-Ranges
Header unset Connection
Header unset Content-Type
</IfModule>
一些标题仍然在这里:
Cache-Control:no-cache
Connection:Keep-Alive
Content-Type:application/json
Date:Wed, 31 Dec 2014 13:48:20 GMT
Keep-Alive:timeout=5, max=100
Server:Apache
Transfer-Encoding:chunked
经过大量尝试后,我认为它是apache服务器下可用的最小标头。