)
return false, nil
}
+ msg := fmt.Sprintf(
+ "%s %s\t%d (%s)\t%s",
+ req.Method, req.URL,
+ code, codeName,
+ cols[1],
+ )
if 40 <= code && code <= 49 {
w.Header().Add("Content-Type", "text/plain")
w.WriteHeader(http.StatusBadGateway)
fmt.Fprintf(w, "%s\n%d (%s)\n", cols[1], code, codeName)
+ fifos.LogNonOK <- msg
return false, nil
}
if 50 <= code && code <= 59 {
w.Header().Add("Content-Type", "text/plain")
w.WriteHeader(http.StatusBadGateway)
fmt.Fprintf(w, "%s\n%d (%s)\n", cols[1], code, codeName)
+ fifos.LogNonOK <- msg
return false, nil
}
if 60 <= code && code <= 69 {
w.Header().Add("Content-Type", "text/plain")
w.WriteHeader(http.StatusUnauthorized)
fmt.Fprintf(w, "%s\n%d (%s)\n", cols[1], code, codeName)
+ fifos.LogNonOK <- msg
return false, nil
}
if !(20 <= code && code <= 29) {
err = fmt.Errorf("unknown response code: %d", code)
log.Printf("%s: %s\n", req.URL, err)
+ fifos.LogNonOK <- msg
return false, err
}
contentType := strings.Split(strings.TrimRight(cols[1], "\r\n"), ";")[0]
}
buf.WriteString("</body></html>\n")
_, err = w.Write(buf.Bytes())
+ fifos.LogOK <- msg
return false, err
}
w.Header().Add("Content-Type", contentType)
if err != nil {
log.Printf("%s: can not read response body: %+v\n", req.URL, err)
}
+ fifos.LogOK <- msg
return false, err
}