Skip to content

fix: Invalidate the request URL even when the response has no headers - #153

Merged
georgeguimaraes merged 1 commit into
masterfrom
fix/delete-nil-headers
Sep 15, 2026
Merged

georgeguimaraes merged 1 commit into
masterfrom
fix/delete-nil-headers

Conversation

@georgeguimaraes

Copy link
Copy Markdown
Member

Fixes #142. On an unsafe method, a response cut short by a timeout or reset arrives with status 0 and no headers, should_delete? lets it through, and delete raised NoMethodError reading Location from nil inside on_complete. Treat missing headers as empty and still invalidate the request URL.

The spec uses a tiny adapter that finishes the env with response_headers = nil, since the :test adapter normalizes nil into an empty header set and can't reproduce this. It raises the reported error against master and passes here, on Faraday 2 and 1.

A response cut short by a timeout or a connection reset can reach the delete path with nil headers, and reading Location out of it raised NoMethodError inside on_complete. Fall back to an empty header set so the request URL is still invalidated.

Fixes #142
@georgeguimaraes
georgeguimaraes merged commit e7aa611 into master Sep 15, 2026
10 checks passed
@georgeguimaraes
georgeguimaraes deleted the fix/delete-nil-headers branch September 15, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NoMethodError: undefined method '[]' for nil in HttpCache#delete when response has nil headers

1 participant