Merge branch '14715-keepprox-config'
[arvados.git] / sdk / go / arvados / client.go
index e55cb82f2a353f95c1f57bfe168de48a852f619f..a5815987b192a86c9ee646205bcc9ea0f7986dcc 100644 (file)
@@ -121,16 +121,16 @@ var reqIDGen = httpserver.IDGenerator{Prefix: "req-"}
 // Do adds Authorization and X-Request-Id headers and then calls
 // (*http.Client)Do().
 func (c *Client) Do(req *http.Request) (*http.Response, error) {
-       if auth, _ := req.Context().Value("Authorization").(string); auth != "" {
+       if auth, _ := req.Context().Value(contextKeyAuthorization{}).(string); auth != "" {
                req.Header.Add("Authorization", auth)
        } else if c.AuthToken != "" {
                req.Header.Add("Authorization", "OAuth2 "+c.AuthToken)
        }
 
        if req.Header.Get("X-Request-Id") == "" {
-               reqid, _ := req.Context().Value(contextKeyRequestID).(string)
+               reqid, _ := req.Context().Value(contextKeyRequestID{}).(string)
                if reqid == "" {
-                       reqid, _ = c.context().Value(contextKeyRequestID).(string)
+                       reqid, _ = c.context().Value(contextKeyRequestID{}).(string)
                }
                if reqid == "" {
                        reqid = reqIDGen.Next()
@@ -203,6 +203,17 @@ func anythingToValues(params interface{}) (url.Values, error) {
                        urlValues.Set(k, v.String())
                        continue
                }
+               if v, ok := v.(bool); ok {
+                       if v {
+                               urlValues.Set(k, "true")
+                       } else {
+                               // "foo=false", "foo=0", and "foo="
+                               // are all taken as true strings, so
+                               // don't send false values at all --
+                               // rely on the default being false.
+                       }
+                       continue
+               }
                j, err := json.Marshal(v)
                if err != nil {
                        return nil, err