-
Notifications
You must be signed in to change notification settings - Fork 517
Fixes how Python Workers treats duplicate headers #5915
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
base: main
Are you sure you want to change the base?
Conversation
…as and distinct Set-Cookie values
| def _preserve_request_header_commas() -> bool: | ||
| try: | ||
| import _cloudflare_compat_flags as compat_flags | ||
| except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| except Exception: | |
| except ImportError: |
| except Exception: | ||
| return False | ||
|
|
||
| return bool(getattr(compat_flags, "python_request_headers_preserve_commas", False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the bool part?
| return bool(getattr(compat_flags, "python_request_headers_preserve_commas", False)) | |
| return getattr(compat_flags, "python_request_headers_preserve_commas", False) |
| return hasattr(val, "constructor") and val.constructor.name == js_cls_name | ||
|
|
||
|
|
||
| def _preserve_request_header_commas() -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make this into a helper method like this:
try:
import _cloudflare_compat_flags
except ImportError:
_cloudflare_compat_flags = object()
def get_compat_flag(flag: string) -> bool:
return getattr(_cloudflare_compat_flags, flag, false)
ryanking13
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for handling this.
| pythonRequestHeadersPreserveCommas @155 :Bool | ||
| $compatEnableFlag("python_request_headers_preserve_commas") | ||
| $compatDisableFlag("disable_python_request_headers_preserve_commas") | ||
| $compatEnableDate("2026-02-04"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious why are we setting the compat date to a lot future?
Based on #5678 (thank you @n3rada for reporting and helping out with the fix)
All duplicate headers except Set-Cookie will now be added to Python's http.client.HTTPMessage combined and separated by commas.
Test Plan