예제 #1
0
파일: session.go 프로젝트: d1p/goparse
// Create a request which is set headers for Parse API
func (s *ParseSession) initRequest(req *gorequest.SuperAgent, useMaster bool) {
	if useMaster {
		req.
			Set(headerAppID, s.client.ApplicationID).
			Set(headerMasterKey, s.client.MasterKey).
			Timeout(s.client.TimeOut)
	} else {
		req.
			Set(headerAppID, s.client.ApplicationID).
			Set(headerAPIKey, s.client.RESTAPIKey).
			Timeout(s.client.TimeOut)
	}

	if s.SessionToken != "" {
		req.Set(headerSessionToken, s.SessionToken)
	}
}
예제 #2
0
func getRequest(job models.Job) *gorequest.SuperAgent {
	var request = gorequest.New()
	var r *gorequest.SuperAgent

	if job.HTTPVerb == gorequest.GET {
		r = request.Get(job.URI)
	}

	if job.HTTPVerb == gorequest.POST {
		r = request.Post(job.URI)
	}
	r.Timeout(time.Second * 20)

	for key, header := range job.Headers {
		r.Set(key, interfaceToString(header))
	}
	return r
}
예제 #3
0
func setHeadersFromMock(req *gorequest.SuperAgent, mock Mock) {
	for header, val := range mock.HttpRequest.Headers {
		req.Set(header, val)
	}
}