Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement Flusher and Hijacker for codeCatcher #5376

Merged
merged 1 commit into from
Sep 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions middlewares/errorpages/error_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,21 @@ func (cc *codeCatcher) WriteHeader(code int) {
cc.code = code
}

// Hijack hijacks the connection
func (cc *codeCatcher) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if hj, ok := cc.responseWriter.(http.Hijacker); ok {
return hj.Hijack()
}
return nil, nil, fmt.Errorf("%T is not a http.Hijacker", cc.responseWriter)
}

// Flush sends any buffered data to the client.
func (cc *codeCatcher) Flush() {
if flusher, ok := cc.responseWriter.(http.Flusher); ok {
flusher.Flush()
}
}

type responseRecorder interface {
http.ResponseWriter
http.Flusher
Expand Down