title: Go HTTP Request with Basic Auth returning a 401 instead of a 301 redirect
body: <p>Using Go 1.5.1.</p>
  
  <p>When I try to make a request to a site that automatically redirects to HTTPS using Basic Auth I would expect to get a 301 Redirect response, instead I get a 401.</p>
  
  <pre><code>package main
  
  import "net/http"
  import "log"
  
  func main() {
      url := "http://aerolith.org/files"
      username := "cesar"
      password := "password"
      req, err := http.NewRequest("GET", url, nil)
      if err != nil {
          log.Println("error", err)
      }
      if username != "" || password != "" {
          req.SetBasicAuth(username, password)
          log.Println("[DEBUG] Set basic auth to", username, password)
      }
      cli := &amp;http.Client{
  
      }
      resp, err := cli.Do(req)
      if err != nil {
          log.Println("Do error", err)
      }
      log.Println("[DEBUG] resp.Header", resp.Header)
      log.Println("[DEBUG] req.Header", req.Header)
      log.Println("[DEBUG] code", resp.StatusCode)
  
  }
  </code></pre>
  
  <p>Note that curl returns a 301:</p>
  
  <pre><code>curl -vvv http://aerolith.org/files --user cesar:password
  </code></pre>
  
  <p>Any idea what could be going wrong? </p>