mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-29 21:31:41 +00:00
Merge pull request #1598 from tw4452852/1589
proxy: recognize client's cancellation
This commit is contained in:
commit
49d79d7ebc
7 changed files with 87 additions and 41 deletions
|
|
@ -8,6 +8,7 @@ var (
|
|||
_ error = NonHijackerError{}
|
||||
_ error = NonFlusherError{}
|
||||
_ error = NonCloseNotifierError{}
|
||||
_ error = NonPusherError{}
|
||||
)
|
||||
|
||||
// NonHijackerError is more descriptive error caused by a non hijacker
|
||||
|
|
@ -42,3 +43,14 @@ type NonCloseNotifierError struct {
|
|||
func (c NonCloseNotifierError) Error() string {
|
||||
return fmt.Sprintf("%T is not a closeNotifier", c.Underlying)
|
||||
}
|
||||
|
||||
// NonPusherError is more descriptive error caused by a non pusher
|
||||
type NonPusherError struct {
|
||||
// underlying type which doesn't implement pusher
|
||||
Underlying interface{}
|
||||
}
|
||||
|
||||
// Implement Error
|
||||
func (c NonPusherError) Error() string {
|
||||
return fmt.Sprintf("%T is not a pusher", c.Underlying)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package httpserver
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
|
@ -103,7 +102,7 @@ func (r *ResponseRecorder) Push(target string, opts *http.PushOptions) error {
|
|||
return pusher.Push(target, opts)
|
||||
}
|
||||
|
||||
return errors.New("push is unavailable (probably chained http.ResponseWriter does not implement http.Pusher)")
|
||||
return NonPusherError{Underlying: r.ResponseWriter}
|
||||
}
|
||||
|
||||
// Interface guards
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue