Skip to content

Commit

Permalink
Merge pull request #72 from 2manymws/fix-defer-nil
Browse files Browse the repository at this point in the history
Remember that the request may be nil
  • Loading branch information
k1LoW authored Mar 1, 2024
2 parents d93c498 + ad43a38 commit 2a3bfb2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rfc9111/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ func (s *Shared) Storable(req *http.Request, res *http.Response, now time.Time)
func (s *Shared) Handle(req *http.Request, cachedReq *http.Request, cachedRes *http.Response, do func(*http.Request) (*http.Response, error), now time.Time) (useCached bool, r *http.Response, _ error) {
defer func() {
// 5.1 Age (https://httpwg.org/specs/rfc9111.html#rfc.section.5.1)
setAgeHeader(useCached, r.Header, now)
if r != nil {
setAgeHeader(useCached, r.Header, now)
}
}()

if cachedReq == nil || cachedRes == nil {
Expand Down

0 comments on commit 2a3bfb2

Please sign in to comment.