Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPRedirectHandler fails on POST for 307 and 308 #91306

Open
Yajo mannequin opened this issue Mar 29, 2022 · 1 comment
Open

HTTPRedirectHandler fails on POST for 307 and 308 #91306

Yajo mannequin opened this issue Mar 29, 2022 · 1 comment
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Yajo
Copy link
Mannequin

Yajo mannequin commented Mar 29, 2022

BPO 47150
Nosy @orsenthil, @corona10, @yajo

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-03-29.09:26:11.943>
labels = ['type-bug', '3.8', '3.9', '3.10', '3.11', 'library']
title = 'HTTPRedirectHandler fails on POST for 307 and 308'
updated_at = <Date 2022-03-31.00:07:30.666>
user = 'https://github.com/Yajo'

bugs.python.org fields:

activity = <Date 2022-03-31.00:07:30.666>
actor = 'ned.deily'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2022-03-29.09:26:11.943>
creator = 'Jairo Llopis'
dependencies = []
files = []
hgrepos = []
issue_num = 47150
keywords = []
message_count = 1.0
messages = ['416249']
nosy_count = 3.0
nosy_names = ['orsenthil', 'corona10', 'Jairo Llopis']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue47150'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

@Yajo
Copy link
Mannequin Author

Yajo mannequin commented Mar 29, 2022

urllib.request.HTTPRedirectHandler fails if there is a 307 HTTP return code in a POST request.

In c379bc5 the same behaviour was implemented for 308.

According to https://datatracker.ietf.org/doc/html/rfc7538#section-3 IMHO this implementation is wrong for 308:

Note: This status code is similar to 301 (Moved Permanently)
([RFC7231], Section 6.4.2), except that it does not allow changing
the request method from POST to GET.

A similar note exists in https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.7 regarding code 307.

So, as long as the original redirection is in POST and it gets redirected to another POST, it should not be an error.

FWIW, in traefik/traefik#7829 (comment) you can see that Traefik proxy uses 307 and 308 codes by default when redirecting non-GET requests.

Thus, urllib.request.HTTPRedirectHandler will fail to process any POST requests proxied by Traefik.

@Yajo Yajo mannequin added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 29, 2022
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants