use io.Reader when parsing urls
This commit is contained in:
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
@@ -20,9 +22,14 @@ func main() {
|
||||
for p := range spider.Pages(os.Args[1]) {
|
||||
resp, err := http.Get(p.To)
|
||||
if err != nil {
|
||||
p.Err = err
|
||||
failures = append(failures, p)
|
||||
continue
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
p.Err = fmt.Errorf("http status; got %s, want %s", http.StatusText(resp.StatusCode), http.StatusText(http.StatusOK))
|
||||
failures = append(failures, p)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user