Skip to content

Commit b088635

Browse files
fix: transport write new data
1 parent f8077a4 commit b088635

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

http/rw_rfc9111_transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (t *readWriteRFC9111Transport) RoundTrip(req *http.Request) (*http.Response
6565
responseTime := time.Now()
6666

6767
respCC := ParseCacheControl(http.Header(resp.Header), &requestTime, &responseTime, t.sharedCache, ttlSeconds)
68-
if slices.Contains(t.cacheableStatus, resp.StatusCode) && respCC.Cacheable() {
68+
if slices.Contains(t.cacheableStatus, resp.StatusCode) && respCC.Cacheable() && respDB != nil {
6969
newRespDB, err := db.HttpToResponse(resp)
7070
if err == nil {
7171
newRespDB.TableName = respDB.TableName

http/rw_transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (t *readWriteTransport) RoundTrip(req *http.Request) (*http.Response, error
4949
if err != nil || (t.ttl > 0 && time.Since(respDB.ResponseTime) > t.ttl) ||
5050
(len(t.cacheableStatus) > 0 && !slices.Contains(t.cacheableStatus, respDB.Status)) {
5151
resp, err := t.base.RoundTrip(req)
52-
if err == nil {
52+
if err == nil && respDB != nil {
5353
newRespDB, err := db.HttpToResponse(resp)
5454
if err == nil {
5555
newRespDB.TableName = respDB.TableName

0 commit comments

Comments
 (0)