示例#1
0
func (self *Surf) param(req Request) (param *Param, err error) {
	param = new(Param)

	param.url, err = util.UrlEncode(req.GetUrl())
	if err != nil {
		return nil, err
	}

	param.deadline = req.GetDeadline()
	if param.deadline == 0 {
		param.deadline = self.deadline
	}
	param.client = self.buildClient(param.url.Scheme, self.proxy, param.deadline)

	param.referer = req.GetReferer()
	param.header = req.GetHeader()
	param.cookies = req.GetCookies()

	param.pauseTime = req.GetPauseTime()
	if param.pauseTime == 0 {
		param.pauseTime = self.pauseTime
	}

	return param, err
}
示例#2
0
// Post requests the given URL using the POST method.
func (self *Surf) Post(u, ref, contentType string, body io.Reader, header http.Header, cookies []*http.Cookie) (*http.Response, error) {
	urlObj, err := util.UrlEncode(u)
	if err != nil {
		return nil, err
	}
	client := self.buildClient(urlObj.Scheme, self.proxy)
	return self.httpPOST(urlObj, ref, contentType, body, header, cookies, client)
}
示例#3
0
// Open requests the given URL using the HEAD method.
func (self *Surf) Head(u string, header http.Header, cookies []*http.Cookie) (*http.Response, error) {
	urlObj, err := util.UrlEncode(u)
	if err != nil {
		return nil, err
	}
	client := self.buildClient(urlObj.Scheme, self.proxy)
	return self.httpHEAD(urlObj, "", header, cookies, client)
}