aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-24 08:22:12 -0500
committerAdnan Maolood <[email protected]>2021-02-24 08:22:12 -0500
commitb488146cc6a42cfaa7e85ca77a7dddbd02a68595 (patch)
treefdda28004bae5c54b4841dcc3b43ecaafcbb404b
parentImplement TimeoutHandler by wrapping ResponseWriter (diff)
downloadgo-gemini-b488146cc6a42cfaa7e85ca77a7dddbd02a68595.tar.xz
go-gemini-b488146cc6a42cfaa7e85ca77a7dddbd02a68595.zip
Remove ResponseWriter.Hijack method
-rw-r--r--gemini.go7
-rw-r--r--response.go30
2 files changed, 0 insertions, 37 deletions
diff --git a/gemini.go b/gemini.go
index add3f85..6228526 100644
--- a/gemini.go
+++ b/gemini.go
@@ -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")
)
diff --git a/response.go b/response.go
index 2ab3bfd..487e58b 100644
--- a/response.go
+++ b/response.go
@@ -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() {}