Remove ResponseWriter.Hijack method

This commit is contained in:
Adnan Maolood 2021-02-24 08:22:12 -05:00
parent 069b473c28
commit b488146cc6
2 changed files with 0 additions and 37 deletions

View File

@ -16,11 +16,4 @@ var (
// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
// when the response status code does not permit a 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")
)

View File

@ -163,18 +163,6 @@ type ResponseWriter interface {
// TLS returns information about the underlying TLS connection.
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
// without breaking existing code. Implementers must embed a concrete
// type from elsewhere.
@ -187,7 +175,6 @@ type responseWriter struct {
mediatype string
wroteHeader bool
bodyAllowed bool
hijacked bool
conn net.Conn
}
@ -203,9 +190,6 @@ func (w *responseWriter) SetMediaType(mediatype string) {
}
func (w *responseWriter) Write(b []byte) (int, error) {
if w.hijacked {
return 0, ErrHijacked
}
if !w.wroteHeader {
meta := w.mediatype
if meta == "" {
@ -221,9 +205,6 @@ func (w *responseWriter) Write(b []byte) (int, error) {
}
func (w *responseWriter) WriteHeader(status Status, meta string) {
if w.hijacked {
return
}
if w.wroteHeader {
return
}
@ -240,9 +221,6 @@ func (w *responseWriter) WriteHeader(status Status, meta string) {
}
func (w *responseWriter) Flush() error {
if w.hijacked {
return ErrHijacked
}
if !w.wroteHeader {
w.WriteHeader(StatusTemporaryFailure, "Temporary failure")
}
@ -251,9 +229,6 @@ func (w *responseWriter) Flush() error {
}
func (w *responseWriter) Close() error {
if w.hijacked {
return ErrHijacked
}
return w.cl.Close()
}
@ -269,9 +244,4 @@ func (w *responseWriter) TLS() *tls.ConnectionState {
return nil
}
func (w *responseWriter) Hijack() net.Conn {
w.hijacked = true
return w.conn
}
func (w *responseWriter) unexported() {}