@@ -90,10 +90,6 @@ func detectVcsFromRemote(vcsURL string) (Type, string, error) {
90
90
return t , vcsURL , nil
91
91
}
92
92
93
- // Need to test for vanity or paths like golang.org/x/
94
-
95
- // TODO: Test for 3xx redirect codes and handle appropriately.
96
-
97
93
// Pages like https://golang.org/x/net provide an html document with
98
94
// meta tags containing a location to work with. The go tool uses
99
95
// a meta tag with the name go-import which is what we use here.
@@ -117,10 +113,14 @@ func detectVcsFromRemote(vcsURL string) (Type, string, error) {
117
113
return NoVCS , "" , ErrCannotDetectVCS
118
114
}
119
115
defer resp .Body .Close ()
116
+ if resp .StatusCode < 200 || resp .StatusCode >= 300 {
117
+ return NoVCS , "" , ErrCannotDetectVCS
118
+ }
120
119
121
120
t , nu , err := parseImportFromBody (u , resp .Body )
122
121
if err != nil {
123
- return NoVCS , "" , err
122
+ // TODO(mattfarina): Log the parsing error
123
+ return NoVCS , "" , ErrCannotDetectVCS
124
124
} else if t == "" || nu == "" {
125
125
return NoVCS , "" , ErrCannotDetectVCS
126
126
}
@@ -299,6 +299,7 @@ func get(url string) ([]byte, error) {
299
299
}
300
300
defer resp .Body .Close ()
301
301
if resp .StatusCode != 200 {
302
+ // TODO(mattfarina): log the failed status
302
303
return nil , fmt .Errorf ("%s: %s" , url , resp .Status )
303
304
}
304
305
b , err := ioutil .ReadAll (resp .Body )
0 commit comments