Go Web:处理请求
处理请求 Request和Response http Requset和Response的内容包括以下几项: Request or response line Zero or more headers An empty line, followed by … … an optional message body 例如一个http Request: GET /Protocols/rfc2616/rfc2616.html HTTP/1.1 Host: www.w3.org User-Agent: Mozilla/5.0 (empty line) 如果是POST方法,在empty line后还包含请求体。 一个http Response: HTTP/1.1 200 OK Content-type: text/html Content-length: 24204 (empty line) and then 24,204 bytes of HTML code go http包分为两种角色:http Client和http Server。http Client可以发送请求,比如写爬虫程序时语言扮演的角色就是http Client;http Server用来提供web服务,可以处理http请求并响应。 对于Request,作为http客户端(如编写爬虫类工具)常需要关注的是URL和User