Repository navigation
feat: add bounded HTTP redirect handling - #21
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d4523bcf4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return validate_redirect_url(std::string{location}); | ||
| } | ||
|
|
||
| if (location.rfind("//", 0) == 0) { | ||
| return validate_redirect_url(std::string{"http:"} + std::string{location}); |
There was a problem hiding this comment.
Normalize absolute redirect paths before following them
When Location is an absolute or scheme-relative URI whose path contains dot segments, these branches validate it without applying remove_dot_segments. For example, Location: http://other.test/a/../final is followed as /a/../final rather than the resolved /final; servers that do not normalize the request target can therefore return a different resource. Normalize the parsed path for these reference forms just as for relative paths.
Useful? React with 👍 / 👎.
| } else if (segment != ".") { | ||
| segments.push_back(segment); | ||
| } |
There was a problem hiding this comment.
Preserve empty path segments during dot removal
For redirect paths containing an empty segment immediately before a terminal dot segment, this segment-vector reconstruction loses a slash. For example, /a//. must resolve to /a//, but the function returns /a/ because the empty segment already leaves normalized ending in / and the trailing-slash step adds nothing. Since repeated slashes can identify distinct resources, such redirects may be sent to the wrong target.
Useful? React with 👍 / 👎.
Summary
Implements roadmap milestone v0.7: configurable automatic HTTP redirects for the stateful
Client.Public configuration
Client::set_follow_redirects(bool)Client::set_max_redirects(std::size_t)Supported statuses and method policy
301/302: POST becomes GET and drops its body; other methods are preserved303: all methods except HEAD become GET; body is dropped307/308: method and body are preservedWhen a body is dropped,
Content-Length,Transfer-Encoding, andContent-Typeare not forwarded.Location resolution
Supports:
http://locations//host/pathRedirects to HTTPS or another unsupported scheme return
UnsupportedRedirectScheme.Connection reuse integration
Redirect orchestration sits above a single-request
execute_once()path, so existing v0.6 connection ownership remains unchanged:Cross-origin header safety
Cross-origin redirects do not forward caller-supplied:
HostAuthorizationProxy-AuthorizationCookieOnce stripped during a redirect chain, these fields are not restored automatically.
Structured failures
RedirectLimitExceededMissingRedirectLocationUnsupportedRedirectSchemeTests
Adds unit and loopback integration coverage for:
Also documents the redirect behavior in the public API contract.