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

Loading…
Cancel
Save