func newQuery(id cryptools.NamedSigner, endpoint awsconn.Endpoint, domain, action string, params map[string]string) (hreq *http.Request, err os.Error) { if params == nil { params = make(map[string]string) } req := &Request{ //Method: method, Host: endpoint.GetURL().Host, URL: &http.URL{ Scheme: endpoint.GetURL().Scheme, Host: endpoint.GetURL().Host, Path: endpoint.GetURL().Path, }, } if req.URL.Path == "" { req.URL.Path = "/" } if _, ok := params["Version"]; !ok { params["Version"] = DEFAULT_VERSION } if _, ok := params["SignatureVersion"]; !ok { params["SignatureVersion"] = DEFAULT_SIGNATURE_VERSION } if _, ok := params["SignatureMethod"]; !ok { params["SignatureMethod"] = DEFAULT_SIGNATURE_METHOD } if _, ok := params["Timestamp"]; !ok { params["Timestamp"] = time.UTC().Format("2006-01-02T15:04:05-07:00") } // ListDomains, Select don't require a DomainName attribute if domain != "" { params["DomainName"] = domain } params["Action"] = action params["AWSAccessKeyId"] = id.SignerName() req.Form = maptools.StringStringToStringStrings(params) if len(http.EncodeQuery(req.Form)) > 512 { req.Method = "POST" } else { req.Method = "GET" } if _, ok := params["Signature"]; !ok { err = req.Sign(id) } if err == nil { hreq = (*http.Request)(req) } return }
func (self *Queue) signedRequest(id cryptools.NamedSigner, params map[string]string) (req *http.Request, err os.Error) { req = self.Endpoint.NewHTTPRequest("GET", self.Endpoint.GetURL().Path, maptools.StringStringToStringStrings(params), nil) req.Form["AWSAccessKeyId"] = []string{id.SignerName()} if len(req.Form["Version"]) == 0 { req.Form["Version"] = []string{DefaultSQSVersion} } if len(req.Form["SignatureMethod"]) == 0 { req.Form["SignatureMethod"] = []string{DefaultSignatureMethod} } if len(req.Form["SignatureVersion"]) == 0 { req.Form["SignatureVersion"] = []string{DefaultSignatureVersion} } if len(req.Form["Expires"]) == 0 && len(req.Form["Timestamp"]) == 0 { req.Form["Timestamp"] = []string{strconv.Itoa64(time.Seconds())} } err = SignRequest(id, req) return }
func calculateCobrandingURL(id cryptools.NamedSigner, endpoint *awsconn.Endpoint, params map[string]string) (hreq *http.Request, err os.Error) { if params == nil { params = make(map[string]string) } req := &Request{ //Method: method, Host: endpoint.GetURL().Host, URL: &http.URL{ Scheme: endpoint.GetURL().Scheme, Host: endpoint.GetURL().Host, Path: endpoint.GetURL().Path, }, } if req.URL.Path == "" { req.URL.Path = "/" } if _, ok := params["Version"]; !ok { params["Version"] = DEFAULT_VERSION } if _, ok := params["SignatureVersion"]; !ok { params["SignatureVersion"] = DEFAULT_SIGNATURE_VERSION } if _, ok := params["SignatureMethod"]; !ok { params["SignatureMethod"] = DEFAULT_SIGNATURE_METHOD } // Timestamp is only mandatory on certain contexts. //if _, ok := params["Timestamp"]; ! ok { params["Timestamp"] = time.UTC().Format("2006-01-02T15:04:05-07:00")} // ListDomains, Select don't require a DomainName attribute params["callerKey"] = id.SignerName() req.Form = maptools.StringStringToStringStrings(params) req.Method = "GET" if _, ok := params["Signature"]; !ok { err = req.Sign(id) } if err == nil { hreq = (*http.Request)(req) } return }
// Constructs a query request object; This complex type implements // both the Canonicalization and Signing methods necessary to access // S3. // // For the most part, users are expected to use the exposed bucket/endpoint/obj // functions // // If Expiration is < 1 year (in seconds), the expiration is assumed to // mean seconds-from-now (local clock based). func NewQueryRequest(id cryptools.NamedSigner, endpoint *awsconn.Endpoint, method, bucket, key, ctype, cmd5 string, params, hdrs map[string]string) (req *http.Request, err os.Error) { req = &http.Request{ Method: method, Host: endpoint.GetURL().Host, URL: &http.URL{ Scheme: endpoint.GetURL().Scheme, Host: endpoint.GetURL().Host, Path: endpoint.GetURL().Path, }, Header: hdrs, Form: maptools.StringStringToStringStrings(params), } if req.Header == nil { req.Header = make(map[string]string) } if ctype != "" { req.Header["Content-Type"] = ctype } if cmd5 != "" { req.Header["Content-Md5"] = cmd5 } if bucket != "" { req.URL.Path = "/" + bucket if key != "" { req.URL.Path += "/" + key } } req.Form["AWSAccessKeyId"] = []string{id.SignerName()} if len(req.Form["Expires"]) == 0 { req.Form["Expires"] = []string{strconv.Itoa64(time.Seconds() + 30)} } if len(req.Form["Signature"]) == 0 { sig, err := cryptools.SignString64(id, base64.StdEncoding, cryptools.SignableString(CanonicalString(req))) if err != nil { return } req.Form["Signature"] = []string{sig} } return }