fix(http): skip caching relative 307 redirect locations and resolve them#1777
Merged
fix(http): skip caching relative 307 redirect locations and resolve them#1777
Conversation
Signed-off-by: Gaius <gaius.qi@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1777 +/- ##
==========================================
+ Coverage 44.54% 44.66% +0.12%
==========================================
Files 91 91
Lines 25834 25905 +71
==========================================
+ Hits 11508 11571 +63
- Misses 14326 14334 +8
🚀 New features to boost your workflow:
|
imeoer
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request improves how HTTP 307 Temporary Redirects are handled and cached in the
dragonfly-client-backend. The main focus is to ensure that only absolute URLs are cached as redirect targets, preventing potential issues with relative URLs. Additionally, a new test verifies this behavior.Redirect handling and caching improvements:
store_temporary_redirect_urlto skip caching redirects when theLocationheader is a relative URL, logging a debug message in such cases. Only absolute URLs are now cached as valid redirect targets.Redirect resolution and request flow:
Locationheaders are joined with the base URL to form an absolute URL before following the redirect. However, only the originalLocationvalue (not the resolved absolute URL) is considered for caching, aligning with the new caching logic. This change is applied in both thestatandgetrequest flows. [1] [2]Testing:
should_not_cache_relative_307_redirect_locationto verify that relative redirect URLs are not cached, ensuring the origin server is contacted again for subsequent requests.Related Issue
Fixed dragonflyoss/dragonfly#4710
Motivation and Context
Screenshots (if appropriate)