Browse Source

Record the first written status, not the last

If WriteHeader is called multiple times on a http.ResponseWriter, the
first status is the one that is used, not the last. Fix the wrapped
writer to reflect this fact.
Carl Jackson 12 years ago
parent
commit
1c4f21ce5f
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      web/middleware/writer_proxy.go

+ 5
- 3
web/middleware/writer_proxy.go View File

@ -33,9 +33,11 @@ type basicWriter struct {
} }
func (b *basicWriter) WriteHeader(code int) { func (b *basicWriter) WriteHeader(code int) {
b.code = code
b.wroteHeader = true
b.ResponseWriter.WriteHeader(code)
if !b.wroteHeader {
b.code = code
b.wroteHeader = true
b.ResponseWriter.WriteHeader(code)
}
} }
func (b *basicWriter) Write(buf []byte) (int, error) { func (b *basicWriter) Write(buf []byte) (int, error) {
b.maybeWriteHeader() b.maybeWriteHeader()


Loading…
Cancel
Save