Skip to content

Commit

Permalink
Reset buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Jun 14, 2024
1 parent be07799 commit 32077f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rc.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (m *cacheMw) duplicateRequest(req *http.Request) (*http.Request, *http.Requ
func (m *cacheMw) handlerToRequester(h http.Handler, reqc *http.Request, now time.Time) func(*http.Request) (*http.Response, error) {
return func(req *http.Request) (*http.Response, error) {
rec := newRecorder()
defer rec.Reset()
h.ServeHTTP(rec, req)
res := rec.Result()

Expand Down Expand Up @@ -286,6 +287,12 @@ func (r *recorder) Result() *http.Response {
}
}

func (r *recorder) Reset() {
r.statusCode = 0
r.header = make(http.Header)
r.buf.Reset()
}

func contains(s []string, e string) bool {
for _, v := range s {
if e == v {
Expand Down

0 comments on commit 32077f4

Please sign in to comment.