[英]HTTP headers automatically set
I am starting to learn about http correctly. 我开始正确地学习http。
I am working in lamp stack. 我在灯堆里工作。
On the command line i am requesting a local page which will be served with apache to see the headers that are returned. 在命令行上,我请求一个本地页面,该页面将与apache一起查看返回的标头。
curl -i local.testsite
The page i am requesting has no content and i am not setting any headers but there are already a lot of headers sent in the response such as: 我请求的页面没有内容,并且我没有设置任何标题,但是响应中已经发送了很多标题,例如:
HTTP/1.1 200 OK
Date: Thu, 17 Jan 2013 20:28:52 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.4
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html
So if i am not setting these, does apache set these automatically? 所以,如果我没有设置这些,Apache是否会自动设置?
Some are set by PHP: 有些是由PHP设置的:
X-Powered-By
header is set by the expose_php
INI setting. X-Powered-By
标头由expose_php
INI设置设置。 Content-Type
header is set by the default_mimetype
INI setting. Content-Type
标头由default_mimetype
INI设置设置。 The others are set by Apache: 其他由Apache设置:
Server
header is set by the ServerSignature
directive. Server
标头由ServerSignature
指令设置。 Vary: Accept-Encoding
header is usually sent when mod_deflate
is enabled. mod_deflate
时,通常发送Vary: Accept-Encoding
标头。 Date
and Content-Length
are not configurable as they are part of the HTTP spec. Date
和Content-Length
不可配置,因为它们是HTTP规范的一部分。 Date
is included as a MUST (except under some conditions) and Content-Length
as a SHOULD . 必须将
Date
( 必须在某些情况下除外) 包括在内,将 Content-Length
应 包括在内 。
See also How to remove date header from apache? 另请参阅如何从apache中删除日期标头? and How to disable the Content-Length response header with Apache?
以及如何使用Apache禁用Content-Length响应标头? .
。
Yes Apache is setting those by default. 是的,Apache默认设置这些设置。 By the way, if you only care about the headers, you should use
顺便说一句,如果您只关心标题,则应使用
curl -I local.testsite
-I
returns the headers only (HTTP HEAD request), such that even if you had content on the page you would only get the header. -I
仅返回标头(HTTP HEAD请求),这样,即使页面上有内容,您也只会获得标头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.