http协议基于socket接口实现

HTTP:REST架构,C/S模式,请求类型:GET、PUT、HEAD、POST。

1、client端发送get包:"GET /pub/WWW/TheProject.html HTTP/1.1\r\nHost: www.w3.org\r\n"

GET /hello.htm HTTP/1.1
Accept: */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
If-Modified-Since: Wed, 17 Oct 2007 02:15:55 GMT
If-None-Match: W/"158-1192587355000"
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Host: 192.168.2.162:8080
Connection: Keep-Alive
响应包:
HTTP/1.1 200 OK
ETag: W/"158-1192590101000"
Last-Modified: Wed, 17 Oct 2007 03:01:41 GMT
Content-Type: text/html
Content-Length: 158
Date: Wed, 17 Oct 2007 03:01:59 GMT
Server: Apache-Coyote/1.1/
 
 ------<body>-------
2、client端发送post包:
 POST /form/entry HTTP/1.1
    Host: hackr.jp
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 16
    
 name=ueno&age=37
 响应包:
 HTTP/1.1 200 OK
 Date: Tue, 10 Jul 2012 06:20:15 GMT(响应首部字段)
 Content-Length: 362
 Content-Type: text/html
 
 <html>
 ...
3、client端发送head包:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
posted @ 2020-09-10 14:41  木木布姆  阅读(277)  评论(0)    收藏  举报