Skip to content

Commit ad43a38

Browse files
committed
Remember that the request may be nil
1 parent d93c498 commit ad43a38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rfc9111/shared.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ func (s *Shared) Storable(req *http.Request, res *http.Response, now time.Time)
198198
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) {
199199
defer func() {
200200
// 5.1 Age (https://httpwg.org/specs/rfc9111.html#rfc.section.5.1)
201-
setAgeHeader(useCached, r.Header, now)
201+
if r != nil {
202+
setAgeHeader(useCached, r.Header, now)
203+
}
202204
}()
203205

204206
if cachedReq == nil || cachedRes == nil {

0 commit comments

Comments
 (0)