I am starting to learn about http correctly.
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.
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?
Some are set by PHP:
X-Powered-By
header is set by the expose_php
INI setting. Content-Type
header is set by the default_mimetype
INI setting. The others are set by Apache:
Server
header is set by the ServerSignature
directive. Vary: Accept-Encoding
header is usually sent when mod_deflate
is enabled. Date
and Content-Length
are not configurable as they are part of the HTTP spec. Date
is included as a MUST (except under some conditions) and Content-Length
as a SHOULD .
See also How to remove date header from apache? and How to disable the Content-Length response header with Apache? .
Yes Apache is setting those by default. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.