
http协议
以下皆引用自rfc2616
HTTP communication usually takes place over TCP/IP connections.
HTTP 通讯常通过TCP/IP连接进行
http_URL = “http:” “//“ host [ “:” port ] [ abs_path [ “?” query ]]
http_URL格式,重点在问号
The Method token indicates the method to be performed on the
resource identified by the Request-URI. The method is case-sensitive.
http方法,代码只实现了GET,POST
Method = "OPTIONS" ; Section 9.2
| "GET" ; Section 9.3
| "HEAD" ; Section 9.4
| "POST" ; Section 9.5
| "PUT" ; Section 9.6
| "DELETE" ; Section 9.7
| "TRACE" ; Section 9.8
| "CONNECT" ; Section 9.9
| extension-method
extension-method = token
状态码,代码实现了200,400,404,500,501
1 |
Status-Code = |
The Content-Type entity-header field indicates the media type of
the entity-body sent to the recipient or, in the case of the HEAD
method, the media type that would have been sent had the request
been a GET.Content-Type = "Content-Type" ":" media-typeMedia types are defined in section 3.7. An example of the field is
Content-Type: text/html; charset=ISO-8859-4
tinyhttpd
rfc2616是1999年头发布的,该代码写于1999年底,是一个小型的http服务器。
代码流程
|main—–tcp port—–accept—–pthread_create—–exit
|………………………………^—————-|
|…………………………………………………|
|……………………………………….accept_request
|………………………………………../…………………
|……………………………………… /…………………..
|……………………………………GET………………POST
|………………………………………|…………………….|
|……………………………………….…………………../
|…………………………………………………………./
|……………………………………..cgi == 0 || cgi == 1
|…………………………………………/………………..
|………………………………………../………………….
|……………………………….serve_file…………. execute_cgi




近期评论