Permalink
Browse files

Ensure that meta requests include a non empty path.

This is the correct thing to do and fixes a problem with a poorly
configured server. The server in question returns differnt documents for
https://domain, https://domain/ and http://domain/. The server also has
an invalid certificate. The "go get" command skates through the mess
because it errors out on the https requests. The production urlfetch
service does not error out on these requests.
  • Loading branch information...
1 parent 8ea4064 commit 0ad8f5a7af352d669d97bba9263f4f50df49ff6a @garyburd garyburd committed Jul 8, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 doc/doc.go
View
11 doc/doc.go
@@ -52,14 +52,21 @@ func attrValue(attrs []xml.Attr, name string) string {
func getMeta(client *http.Client, importPath string) (projectRoot, projectName, projectURL, repoRoot string, err error) {
var resp *http.Response
+ uri := importPath
+ if !strings.Contains(uri, "/") {
+ // Add slash for root of domain.
+ uri = uri + "/"
+ }
+ uri = uri + "?go-get=1"
+
proto := "https://"
- resp, err = client.Get(proto + importPath + "?go-get=1")
+ resp, err = client.Get(proto + uri)
if err != nil || resp.StatusCode != 200 {
if err == nil {
resp.Body.Close()
}
proto = "http://"
- resp, err = client.Get(proto + importPath + "?go-get=1")
+ resp, err = client.Get(proto + uri)
if err != nil {
err = GetError{strings.SplitN(importPath, "/", 2)[0], err}
return

0 comments on commit 0ad8f5a

Please sign in to comment.