// Poll executes an HTTP HEAD request for url // and returns the HTTP status string or an error string. func (r *Resource) Poll() string { resp, err := http.Head(r.url) if err != nil { log.Println("Error", r.url, err) r.errCount++ return err.String() } r.errCount = 0 return resp.Status }
func apUserExists(username string) (isuser bool) { url_ := "http://www.anime-planet.com/users/" + url.QueryEscape(username) r, err := http.Head(url_) if err != nil { return false } if r.StatusCode == 200 { return true } r.Body.Close() return false }
func get() { url := <-randURL r, err := http.Head(url) if err != nil { log.Println("get:", err) return } defer r.Body.Close() if _, err := ioutil.ReadAll(r.Body); err != nil { log.Println("get:", err) return } if r.StatusCode != 302 { log.Println("get: wrong StatusCode:", r.StatusCode) } if l := r.Header["Location"]; l != fooUrl { log.Println("get: wrong Location:", l) } stat.In <- "get" }
func get() { url := <-randURL r, err := http.Head(url) if err != nil { log.Println("get:", err) return } defer r.Body.Close() b, err := ioutil.ReadAll(r.Body) if err != nil { log.Println("get:", err) return } if r.StatusCode != 302 { log.Println("get: wrong StatusCode:", r.StatusCode) if r.StatusCode == 500 { log.Printf("Error: %s\n", b) } } if l := r.Header.Get("Location"); l != fooUrl { log.Println("get: wrong Location:", l) } stat.In <- "get" }