Skip to content

fix: add 308 redirect support (RFC 7538)#242

Merged
ml31415 merged 2 commits into
geventhttpclient:masterfrom
jorgetamayo21:fix/add-308-redirect-support
May 9, 2026
Merged

fix: add 308 redirect support (RFC 7538)#242
ml31415 merged 2 commits into
geventhttpclient:masterfrom
jorgetamayo21:fix/add-308-redirect-support

Conversation

@jorgetamayo21
Copy link
Copy Markdown
Contributor

Summary

Add HTTP 308 (Permanent Redirect, RFC 7538) to valid_response_codes and
redirect_resonse_codes in UserAgent. Previously, 308 responses were
treated as errors and never followed.

Changes

  • src/geventhttpclient/useragent.py: Add 308 to both
    valid_response_codes and redirect_resonse_codes frozensets.
  • tests/test_useragent.py: Add check_redirect_308() WSGI handler
    and test_redirect_308() test.

Rationale

RFC 7538 standardized 308 as "Permanent Redirect" — semantically identical
to 301 but preserving the HTTP method (like 307). All other common redirect
statuses (301, 302, 303, 307) were already supported; 308 was the missing
counterpart.

Testing

  • test_redirect_308() passes: 308 → follows Location → 200 OK
  • All 18 existing tests pass unchanged

for item in ("cookie", "cookie2"):
self.headers.discard(item)

def redirect(self, code, location):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please also have a look here. This never got the necessary love to really be RFC compliant, just to be "good enough" for common use cases.

@jorgetamayo21
Copy link
Copy Markdown
Contributor Author

@ml31415 done.

@ml31415 ml31415 merged commit 539608e into geventhttpclient:master May 9, 2026
8 checks passed
@ml31415
Copy link
Copy Markdown
Collaborator

ml31415 commented May 9, 2026

Thanks for your PR.

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.

2 participants