Skip to content

fix: follow 303 redirects with GET and append query data before fragments - #1000

Merged
fengmk2 merged 1 commit into
masterfrom
codex/fix-981-redirect-query
Nov 23, 2026
Merged

fengmk2 merged 1 commit into
masterfrom
codex/fix-981-redirect-query

Conversation

@fengmk2

@fengmk2 fengmk2 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

After a POST, a 303 See Other response directs the client to retrieve the result. Repeating the POST can submit the same data twice. The client now follows the redirect with a GET and drops the request body and its headers. If the destination closes the connection, the client retries the redirected request.

For GET and HEAD, the client previously appended data after the URL fragment. The server never received those parameters. The client now appends them to the existing query before the fragment.

Addresses the 303 redirect and URL fragment reports in #981.

Summary by CodeRabbit

  • Bug Fixes
    • Cross-origin redirects now remove authorization, cookie, and proxy-authorization headers, along with Basic and digest authentication settings.
    • On a 303 redirect from a request other than GET or HEAD, the follow-up request uses GET without the original body or content headers. Other headers are retained, and HEAD requests remain HEAD.
    • GET and HEAD data is added to existing URL query parameters before any fragment, without changing the supplied URL string.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 07:37
@agentscanapp

agentscanapp Bot commented Nov 23, 2026

Copy link
Copy Markdown

Mixed activity

Activity patterns show a mix of organic and automated signals.

View full analysis →

Evidence
  • 24/7 activity pattern: Active in 23 of 24 hours, with the longest break being only 1.7 hours
  • AI agent branches: 8/11 branches use AI agent tool prefixes (codex/)
  • Posts through an AI agent: Codex posted 4 of the account's 16 comments and issues (25%)

Last 1 PR:

This is an automated analysis by AgentScan

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The HTTP client now appends GET and HEAD data to existing URL queries. It also filters sensitive options on cross-origin redirects and changes non-GET/HEAD requests to GET for 303 redirects. Tests cover query construction and redirect behavior.

Changes: HTTP request handling

Layer / File(s) Summary
GET and HEAD query data
src/HttpClient.ts, test/options.data.test.ts
GET and HEAD data is appended to the existing URL query. Tests check query parameters before URL fragments and verify the supplied URL string remains unchanged.
Redirect request options
src/HttpClient.ts, test/options.followRedirect.test.ts
Cross-origin redirects remove sensitive headers and clear authentication options. A 303 from a non-GET/HEAD request switches to GET and clears payload options. Tests check methods, headers, uploads, and a failed redirect target.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

  • Issue 981: The changes address its reported 303 body replay and GET data with URL fragments. The supplied summary does not show a change for the issue’s comma-joined array values in form bodies.

Suggested reviewers: killagu, tremby

Merge Risk: Minimal · up to 54a42

GET and HEAD data is now appended to existing URL queries, and 303 redirects switch to GET without the original body. No material merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two changes that appear in the changeset: following 303 redirects with GET (HttpClient redirect handling and the new followRedirect tests) and appending query data before the URL fragm…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names two changes that appear in the changeset: following 303 redirects with GET (HttpClient redirect handling and the new followRedirect tests) and appending query data before the URL fragment for GET/HEAD (HttpClient URL building and options.data tests). The title is specific and matches the main objectives of the PR, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1502e9f-fd0d-4d42-a43d-ea9866c9d792
Commits

Reviewing files that changed from the base of the PR and between 9d83c80 and 54a4228.

Files selected for processing: 3

  • src/HttpClient.ts
  • test/options.data.test.ts
  • test/options.followRedirect.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/node-modules/urllib@1000

commit: 54a4228

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.07%. Comparing base (9d83c80) to head (54a4228).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1000      +/-   ##
==========================================
+ Coverage   94.91%   95.07%   +0.16%     
==========================================
  Files          10       10              
  Lines         747      751       +4     
  Branches      235      235              
==========================================
+ Hits          709      714       +5     
+ Misses         35       34       -1     
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the redirect and query-handling changes.

No open issues 🎉

What changed in this PR

This PR fixes two HTTP request behaviors in urllib reported in #981: handling 303 redirects and placing GET/HEAD query data before URL fragments.

Changes:

  • Follow 303 redirects from non-GET/HEAD methods with a bodyless GET, removing content headers and body options.
  • Keep redirect-target retries from replaying the original request.
  • Append GET/HEAD data before fragments while preserving existing query parameters and caller-owned URL objects.
File Description
test/​options.followRedirect.test.ts Adds coverage for 303 method conversion, body removal, HEAD preservation, and redirected retries.
test/​options.data.test.ts Tests fragment-safe GET/HEAD queries and preservation of the original URL.
src/​HttpClient.ts Updates redirect handling, header filtering, retry propagation, and query construction.

Review effort: Balanced

@fengmk2

fengmk2 commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T13:23:37.847742Z 54a4228 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 54a422877c

ℹ️ 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".

@fengmk2
fengmk2 merged commit ac7637e into master Nov 23, 2026
30 of 31 checks passed
@fengmk2
fengmk2 deleted the codex/fix-981-redirect-query branch November 23, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants