Documentation ¶
Index ¶
- Constants
- func BuildUrl(baseURL string, params map[string]string) string
- func DoGet(w *Request, r *Response, client *http.Client)
- func DoPost(w *Request, r *Response, client *http.Client)
- func GET(w *Request, r *Response)
- func POST(w *Request, r *Response)
- func StatusErrorMsg(errcode int) string
- func WGetBytes(uri string) ([]byte, error)
- type Request
- func (s *Request) SetContentType(value string)
- func (s *Request) SetCookies(cookies string)
- func (s *Request) SetHeader(k, v string)
- func (s *Request) SetHost(host string)
- func (s *Request) SetReferer(refer string)
- func (s *Request) SetRequestId(id string)
- func (s *Request) SetUserAgent(value string)
- type Response
- type Url
Constants ¶
View Source
const ( ContentTypeJSON = "application/json" ContentTypeXLSX = "application/xlsx" ContentTypeOctetStream = "application/octet-stream" ContentTypeUrlencoded = "application/x-www-form-urlencoded" ContentTypeFormData = "multipart/form-data" ContentTypeXml = "application/xml" ContentTypeBinary = "application/octet-stream" )
View Source
const ( HeaderKeyOfResponseCookies = "Set-Cookie" HeaderKeyOfRequestHost = "Host" HeaderKeyOfRequestCookies = "Cookie" HeaderKeyOfRequestReferer = "Referer" HeaderKeyOfRequestContentType = "Content-Type" HeaderKeyOfRequestUserAgent = "UserAgent" HeaderKeyOfRequestAcceptLang = "Accept-Language" DefaultXffKeyword = "X-Forwarded-For" DefaultXfhKeyword = "X-Forwarded-Host" DefaultXfpKeyword = "X-Forwarded-Proto" DefaultXreqKeyword = "X-Request-ID" )
View Source
const ( AccessControlAllowHeaders = "Access-Control-Allow-Headers" AccessControlAllowMethods = "Access-Control-Allow-Methods" AccessControlAllowOrigin = "Access-Control-Allow-Origin" AccessControlAllowCredentials = "Access-Control-Allow-Credentials" AccessControlMaxAge = "Access-Control-Max-Age" AccessControlExposeHeaders = "Access-Control-Expose-Headers" )
View Source
const (
HTTPStatusOK = http.StatusOK
)
Variables ¶
This section is empty.
Functions ¶
func StatusErrorMsg ¶
Types ¶
type Request ¶
type Request struct { Uri string // The URL we just crawled UserAgent string //指定请求的UserAgent信息 ContentType string // Our content-type ContentLength int64 //返回的数据长度 Body []byte // The actual page content. Headers map[string]string RequestId string Host string }
Request 请求结构
func NewRequest ¶
func NewRequest() *Request
func (*Request) SetContentType ¶
func (*Request) SetCookies ¶
func (*Request) SetReferer ¶
func (*Request) SetRequestId ¶
func (*Request) SetUserAgent ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.