eg: http/1.1 404 not found
http头:任意,客户与服务器使用头相互通信 (#头第1字母大写,:后需有空格)
get /~unixdb/test.html http1.1 #状态行
connection: keep-alive
user-agent: mozilla/4.75 [en] (x11;u;linux 2.2.17 i686)
host: www.myserver.com
accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, text/html, */*
accept-encoding: gzip
accept-language: en
accept-charset: iso-8859-1,*,utf-8
这样,一个典型的get请求的服务器响应:
http1/1 200 ok #http status
date: tue,7 sep 2004 23:35 gmt #http header
server: apache /1.3.12(unix) mod_ssl/2.6.4 openssl/0.9.5a
connection: close
content-type: text/html
<title>testing</title>
testing
http主体:put和post方法需要主体,非可选。在perl中,主体与头使用\n\n(正式分割符序列是\012\015\012\015) 分开
eg:
my $request=<>;
my (@headers,$body);