1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-15 01:34:53 +02:00

Added response already committed logic

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-03-06 11:12:33 -08:00
parent 91bbd38251
commit 05e8fee3de
5 changed files with 57 additions and 33 deletions

View File

@ -3,6 +3,7 @@ package bolt
import (
"bufio"
"errors"
"log"
"net"
"net/http"
)
@ -10,14 +11,21 @@ import (
type (
response struct {
http.ResponseWriter
status int
size int
status int
size int
committed bool
}
)
func (r *response) WriteHeader(c int) {
if r.committed {
// TODO: Warning
log.Println("bolt: response already committed")
return
}
r.status = c
r.ResponseWriter.WriteHeader(c)
r.committed = true
}
func (r *response) Write(b []byte) (n int, err error) {
@ -55,3 +63,8 @@ func (r *response) Status() int {
func (r *response) Size() int {
return r.size
}
func (r *response) reset(rw http.ResponseWriter) {
r.ResponseWriter = rw
r.committed = false
}