diff --git a/website/camweb.go b/website/camweb.go index b783b627f..21739a143 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -286,26 +286,18 @@ func main() { const connTimeoutNanos = 15e9 type withTimeoutListener struct { - l net.Listener + net.Listener timeoutNanos int64 } func (wtl *withTimeoutListener) Accept() (c net.Conn, err os.Error) { - c, err = wtl.l.Accept() + c, err = wtl.Listener.Accept() if err == nil { c.SetTimeout(wtl.timeoutNanos) } return } -func (wtl *withTimeoutListener) Close() os.Error { - return wtl.l.Close() -} - -func (wtl *withTimeoutListener) Addr() net.Addr { - return wtl.l.Addr() -} - type fixUpGitwebUrls struct { handler http.Handler } diff --git a/website/logging.go b/website/logging.go index 6819e6353..c6d4191f0 100644 --- a/website/logging.go +++ b/website/logging.go @@ -1,9 +1,7 @@ package main import ( - "bufio" "fmt" - "io" "log" "os" "http" @@ -12,14 +10,14 @@ import ( ) type logRecord struct { + http.ResponseWriter + time *time.Time ip, method, rawpath string responseBytes int64 responseStatus int userAgent, referer string proto string // "HTTP/1.1" - - rw http.ResponseWriter } type logHandler struct { @@ -57,7 +55,7 @@ func (h *logHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { referer: r.Referer, responseStatus: http.StatusOK, proto: r.Proto, - rw: rw, + ResponseWriter: rw, } h.handler.ServeHTTP(lr, r) h.ch <- lr @@ -117,34 +115,12 @@ func (h *logHandler) logFromChannel() { } func (lr *logRecord) Write(p []byte) (int, os.Error) { - written, err := lr.rw.Write(p) + written, err := lr.ResponseWriter.Write(p) lr.responseBytes += int64(written) return written, err } func (lr *logRecord) WriteHeader(status int) { lr.responseStatus = status - lr.rw.WriteHeader(status) -} - -// Boring proxies: (seems like I should be able to use embedding somehow...) - -func (lr *logRecord) RemoteAddr() string { - return lr.rw.RemoteAddr() -} - -func (lr *logRecord) UsingTLS() bool { - return lr.rw.UsingTLS() -} - -func (lr *logRecord) SetHeader(k, v string) { - lr.rw.SetHeader(k, v) -} - -func (lr *logRecord) Flush() { - lr.rw.Flush() -} - -func (lr *logRecord) Hijack() (io.ReadWriteCloser, *bufio.ReadWriter, os.Error) { - return lr.rw.Hijack() + lr.ResponseWriter.WriteHeader(status) }