Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsch committed Jun 28, 2024
1 parent af333b6 commit 21c408f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions fsttest/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ResponseRecorder struct {
Code int
HeaderMap fsthttp.Header
Body *bytes.Buffer
headersDone bool
headersSent bool
}

// NewRecorder returns an initialized ResponseRecorder.
Expand All @@ -29,19 +29,18 @@ func NewRecorder() *ResponseRecorder {

// Header returns the response headers to mutate within a handler.
func (r *ResponseRecorder) Header() fsthttp.Header {
if !r.headersDone {
if !r.headersSent {
return r.HeaderMap
}
// Once the send the headers, return a copy so any changes
// are discarded.
// Once sent, return a copy so any changes are discarded.
return r.HeaderMap.Clone()
}

// WriteHeader records the response code.
func (r *ResponseRecorder) WriteHeader(code int) {
if !r.headersDone {
if !r.headersSent {
r.Code = code
r.headersDone = true
r.headersSent = true
}
}

Expand Down

0 comments on commit 21c408f

Please sign in to comment.