Skip to content

fix(client): honor request options and redirect semantics - #36

Open
rupayon123 wants to merge 6 commits into
kavix:mainfrom
rupayon123:contribution/http-redirect-correctness-20260911
Open

fix(client): honor request options and redirect semantics#36
rupayon123 wants to merge 6 commits into
kavix:mainfrom
rupayon123:contribution/http-redirect-correctness-20260911

Conversation

@rupayon123

@rupayon123 rupayon123 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Problem and change

HTTP request options were not consistently honored: custom Host headers were ignored, mixed-case HTTP schemes were treated as bare hostnames, timeout annotations discarded the original error, and each redirect restarted the timeout. A fixed 10-second header wait also overrode longer or disabled timeouts. The redirect logic also followed non-redirect 3xx statuses and changed HEAD to GET on 303.

Apply Host through Request.Host, recognize schemes case-insensitively, wrap timeout causes, and use a deadline shared across the redirect chain and body read. Follow only 301/302/303/307/308 and retain HEAD on 303. Remove the separate fixed response-header deadline so the configured request timeout governs the header wait. Deadline cleanup transfers to the returned body so successful responses remain readable.

Validation

Six regression groups failed before their respective fixes. Local HTTP-server tests cover non-redirect status codes, HEAD redirects, virtual hosts, mixed-case schemes, total redirect timeout and deferred body consumption. An 11-second local server verifies both a 30-second timeout and timeout zero; both cases failed at 10 seconds before the fix. Error-chain assertions verify errors.Is/errors.As.

After each fix: env -u NO_COLOR go test ./..., go vet ./..., formatting and diff checks pass. golangci-lint is unavailable locally. Remote CI is tracked separately. Prepared with AI assistance.

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.

1 participant