func (p *Propolis) ListRequest(path string, marker string, maxEntries int, includeAll bool) (listresult *ListBucketResult, err os.Error) { // set up the query string var prefix string // are we scanning a subdirectory or starting at the root? if path != "" { prefix = path + "/" } query := make(url.Values) query.Add("prefix", prefix) // are we scanning just a single directory or getting everything? if !includeAll { query.Add("delimiter", "/") } // are we continuing an earlier scan? if marker != "" { query.Add("marker", marker) } // restrict the maximum number of entries returned query.Add("max-keys", strconv.Itoa(maxEntries)) u := new(url.URL) *u = *p.Url u.RawQuery = query.Encode() // issue the request var resp *http.Response if resp, err = p.SendRequest("GET", false, "", u, nil, "", nil); err != nil { return } if resp.Body != nil { defer resp.Body.Close() } // parse the stuff we care about from the xml result listresult = &ListBucketResult{} if err = xml.Unmarshal(resp.Body, listresult); err != nil { listresult = nil return } return }
func (s *SQS) query(queueUrl string, params map[string]string, resp interface{}) os.Error { params["Timestamp"] = time.UTC().Format(time.RFC3339) var url_ *url.URL var err os.Error var path string if queueUrl != "" { url_, err = url.Parse(queueUrl) path = queueUrl[len(s.Region.SQSEndpoint):] } else { url_, err = url.Parse(s.Region.SQSEndpoint) path = "/" } if err != nil { return err } //url_, err := url.Parse(s.Region.SQSEndpoint) //if err != nil { // return err //} sign(s.Auth, "GET", path, params, url_.Host) url_.RawQuery = multimap(params).Encode() r, err := http.Get(url_.String()) if err != nil { return err } defer r.Body.Close() //dump, _ := http.DumpResponse(r, true) //println("DUMP:\n", string(dump)) //return nil if r.StatusCode != 200 { return buildError(r) } err = xml.Unmarshal(r.Body, resp) return err }