16171: Change issuer config to string to avoid trailing-slash pain.
[arvados.git] / sdk / go / arvados / client.go
index 8545cb969d92f8fbc716175d5c9820f47ed6680a..1e2c07e867e84d6d6719fdd4f9298b005a86c6e9 100644 (file)
@@ -20,7 +20,7 @@ import (
        "strings"
        "time"
 
-       "git.curoverse.com/arvados.git/sdk/go/httpserver"
+       "git.arvados.org/arvados.git/sdk/go/httpserver"
 )
 
 // A Client is an HTTP client with an API endpoint and a set of
@@ -186,7 +186,7 @@ func (c *Client) DoAndDecode(dst interface{}, req *http.Request) error {
                return nil
        case isRedirectStatus(resp.StatusCode):
                // Copy the redirect target URL to dst.RedirectLocation.
-               buf, err := json.Marshal(map[string]string{"RedirectLocation": resp.Header.Get("Location")})
+               buf, err := json.Marshal(map[string]string{"redirect_location": resp.Header.Get("Location")})
                if err != nil {
                        return err
                }
@@ -281,9 +281,8 @@ func (c *Client) RequestAndDecodeContext(ctx context.Context, dst interface{}, m
        }
        if urlValues == nil {
                // Nothing to send
-       } else if method == "GET" || method == "HEAD" || body != nil {
-               // Must send params in query part of URL (FIXME: what
-               // if resulting URL is too long?)
+       } else if body != nil || ((method == "GET" || method == "HEAD") && len(urlValues.Encode()) < 1000) {
+               // Send params in query part of URL
                u, err := url.Parse(urlString)
                if err != nil {
                        return err
@@ -297,6 +296,10 @@ func (c *Client) RequestAndDecodeContext(ctx context.Context, dst interface{}, m
        if err != nil {
                return err
        }
+       if (method == "GET" || method == "HEAD") && body != nil {
+               req.Header.Set("X-Http-Method-Override", method)
+               req.Method = "POST"
+       }
        req = req.WithContext(ctx)
        req.Header.Set("Content-type", "application/x-www-form-urlencoded")
        for k, v := range c.SendHeader {