Remove ResponseWriter.Hijack method
This commit is contained in:
parent
069b473c28
commit
b488146cc6
@ -16,11 +16,4 @@ var (
|
|||||||
// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
|
// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
|
||||||
// when the response status code does not permit a body.
|
// when the response status code does not permit a body.
|
||||||
ErrBodyNotAllowed = errors.New("gemini: response status code does not allow body")
|
ErrBodyNotAllowed = errors.New("gemini: response status code does not allow body")
|
||||||
|
|
||||||
// ErrHijacked is returned by ResponseWriter.Write calls when
|
|
||||||
// the underlying connection has been hijacked using the
|
|
||||||
// Hijacker interface. A zero-byte write on a hijacked
|
|
||||||
// connection will return ErrHijacked without any other side
|
|
||||||
// effects.
|
|
||||||
ErrHijacked = errors.New("gemini: connection has been hijacked")
|
|
||||||
)
|
)
|
||||||
|
30
response.go
30
response.go
@ -163,18 +163,6 @@ type ResponseWriter interface {
|
|||||||
// TLS returns information about the underlying TLS connection.
|
// TLS returns information about the underlying TLS connection.
|
||||||
TLS() *tls.ConnectionState
|
TLS() *tls.ConnectionState
|
||||||
|
|
||||||
// Hijack lets the caller take over the connection.
|
|
||||||
// After a call to Hijack the Gemini server library
|
|
||||||
// will not do anything else with the connection.
|
|
||||||
// It becomes the caller's responsibility to manage
|
|
||||||
// and close the connection.
|
|
||||||
//
|
|
||||||
// The returned net.Conn may have read or write deadlines
|
|
||||||
// already set, depending on the configuration of the
|
|
||||||
// Server. It is the caller's responsibility to set
|
|
||||||
// or clear those deadlines as needed.
|
|
||||||
Hijack() net.Conn
|
|
||||||
|
|
||||||
// unexported method so we can extend this interface over time
|
// unexported method so we can extend this interface over time
|
||||||
// without breaking existing code. Implementers must embed a concrete
|
// without breaking existing code. Implementers must embed a concrete
|
||||||
// type from elsewhere.
|
// type from elsewhere.
|
||||||
@ -187,7 +175,6 @@ type responseWriter struct {
|
|||||||
mediatype string
|
mediatype string
|
||||||
wroteHeader bool
|
wroteHeader bool
|
||||||
bodyAllowed bool
|
bodyAllowed bool
|
||||||
hijacked bool
|
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,9 +190,6 @@ func (w *responseWriter) SetMediaType(mediatype string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *responseWriter) Write(b []byte) (int, error) {
|
func (w *responseWriter) Write(b []byte) (int, error) {
|
||||||
if w.hijacked {
|
|
||||||
return 0, ErrHijacked
|
|
||||||
}
|
|
||||||
if !w.wroteHeader {
|
if !w.wroteHeader {
|
||||||
meta := w.mediatype
|
meta := w.mediatype
|
||||||
if meta == "" {
|
if meta == "" {
|
||||||
@ -221,9 +205,6 @@ func (w *responseWriter) Write(b []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *responseWriter) WriteHeader(status Status, meta string) {
|
func (w *responseWriter) WriteHeader(status Status, meta string) {
|
||||||
if w.hijacked {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if w.wroteHeader {
|
if w.wroteHeader {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -240,9 +221,6 @@ func (w *responseWriter) WriteHeader(status Status, meta string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *responseWriter) Flush() error {
|
func (w *responseWriter) Flush() error {
|
||||||
if w.hijacked {
|
|
||||||
return ErrHijacked
|
|
||||||
}
|
|
||||||
if !w.wroteHeader {
|
if !w.wroteHeader {
|
||||||
w.WriteHeader(StatusTemporaryFailure, "Temporary failure")
|
w.WriteHeader(StatusTemporaryFailure, "Temporary failure")
|
||||||
}
|
}
|
||||||
@ -251,9 +229,6 @@ func (w *responseWriter) Flush() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *responseWriter) Close() error {
|
func (w *responseWriter) Close() error {
|
||||||
if w.hijacked {
|
|
||||||
return ErrHijacked
|
|
||||||
}
|
|
||||||
return w.cl.Close()
|
return w.cl.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,9 +244,4 @@ func (w *responseWriter) TLS() *tls.ConnectionState {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *responseWriter) Hijack() net.Conn {
|
|
||||||
w.hijacked = true
|
|
||||||
return w.conn
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *responseWriter) unexported() {}
|
func (w *responseWriter) unexported() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user