Let hijacker and flusher interfaces to be reflected. (#3709)

Ideally here if the interface is not found it would
fail the server, as it should be because without these
we can't even have a working server in the first place.

Just like how it fails in master invariably inside Go
net/http code path.

Fixes #3708
master
Harshavardhana 8 years ago
parent 70e70446bb
commit a170e44689
  1. 12
      cmd/generic-handlers.go

@ -17,6 +17,8 @@
package cmd
import (
"bufio"
"net"
"net/http"
"path"
"strings"
@ -361,7 +363,6 @@ func (h resourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// to record some useful http response data.
type httpResponseRecorder struct {
http.ResponseWriter
http.Flusher
respStatusCode int
}
@ -372,10 +373,7 @@ func (rww *httpResponseRecorder) Write(b []byte) (int, error) {
// Wraps ResponseWriter's Flush()
func (rww *httpResponseRecorder) Flush() {
f, ok := rww.ResponseWriter.(http.Flusher)
if ok {
f.Flush()
}
rww.ResponseWriter.(http.Flusher).Flush()
}
// Wraps ResponseWriter's WriteHeader() and record
@ -385,6 +383,10 @@ func (rww *httpResponseRecorder) WriteHeader(httpCode int) {
rww.ResponseWriter.WriteHeader(httpCode)
}
func (rww *httpResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return rww.ResponseWriter.(http.Hijacker).Hijack()
}
// httpStatsHandler definition: gather HTTP statistics
type httpStatsHandler struct {
handler http.Handler

Loading…
Cancel
Save