Remove ResponseWriter.Close method
This commit is contained in:
parent
1bc5c68c3f
commit
1764e02d1e
@ -102,7 +102,3 @@ func (w *logResponseWriter) WriteHeader(status gemini.Status, meta string) {
|
||||
func (w *logResponseWriter) Flush() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *logResponseWriter) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
17
handler.go
17
handler.go
@ -14,11 +14,10 @@ import (
|
||||
// ServeGemini should write the response header and data to the ResponseWriter
|
||||
// and then return. Returning signals that the request is finished; it is not
|
||||
// valid to use the ResponseWriter after or concurrently with the completion
|
||||
// of the ServeGemini call. Handlers may also call ResponseWriter.Close to
|
||||
// manually close the connection.
|
||||
// of the ServeGemini call.
|
||||
//
|
||||
// The provided context is canceled when the client's connection is closed,
|
||||
// when ResponseWriter.Close is called, or when the ServeGemini method returns.
|
||||
// The provided context is canceled when the client's connection is closed
|
||||
// or the ServeGemini method returns.
|
||||
//
|
||||
// Handlers should not modify the provided Request.
|
||||
type Handler interface {
|
||||
@ -100,7 +99,7 @@ func (t *timeoutHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *R
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
tw := &timeoutWriter{
|
||||
wc: &contextWriter{
|
||||
wr: &contextWriter{
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
done: ctx.Done(),
|
||||
@ -124,7 +123,7 @@ func (t *timeoutHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *R
|
||||
}
|
||||
|
||||
type timeoutWriter struct {
|
||||
wc io.WriteCloser
|
||||
wr io.Writer
|
||||
status Status
|
||||
meta string
|
||||
mediatype string
|
||||
@ -139,7 +138,7 @@ func (w *timeoutWriter) Write(b []byte) (int, error) {
|
||||
if !w.wroteHeader {
|
||||
w.WriteHeader(StatusSuccess, w.mediatype)
|
||||
}
|
||||
return w.wc.Write(b)
|
||||
return w.wr.Write(b)
|
||||
}
|
||||
|
||||
func (w *timeoutWriter) WriteHeader(status Status, meta string) {
|
||||
@ -154,7 +153,3 @@ func (w *timeoutWriter) WriteHeader(status Status, meta string) {
|
||||
func (w *timeoutWriter) Flush() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *timeoutWriter) Close() error {
|
||||
return w.wc.Close()
|
||||
}
|
||||
|
11
response.go
11
response.go
@ -147,10 +147,6 @@ type ResponseWriter interface {
|
||||
|
||||
// Flush sends any buffered data to the client.
|
||||
Flush() error
|
||||
|
||||
// Close closes the connection.
|
||||
// Any blocked Write operations will be unblocked and return errors.
|
||||
Close() error
|
||||
}
|
||||
|
||||
type responseWriter struct {
|
||||
@ -161,10 +157,9 @@ type responseWriter struct {
|
||||
bodyAllowed bool
|
||||
}
|
||||
|
||||
func newResponseWriter(w io.WriteCloser) *responseWriter {
|
||||
func newResponseWriter(w io.Writer) *responseWriter {
|
||||
return &responseWriter{
|
||||
bw: bufio.NewWriter(w),
|
||||
cl: w,
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +205,3 @@ func (w *responseWriter) Flush() error {
|
||||
// Write errors from WriteHeader will be returned here.
|
||||
return w.bw.Flush()
|
||||
}
|
||||
|
||||
func (w *responseWriter) Close() error {
|
||||
return w.cl.Close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user