Skip to content

Conversation

@dom96
Copy link
Contributor

@dom96 dom96 commented Jan 16, 2026

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

$ bazel run @workerd//src/workerd/server/tests/python:sdk_0.28.2@

def _preserve_request_header_commas() -> bool:
try:
import _cloudflare_compat_flags as compat_flags
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
except Exception:
except ImportError:

except Exception:
return False

return bool(getattr(compat_flags, "python_request_headers_preserve_commas", False))
Copy link
Contributor

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?

Suggested change
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:
Copy link
Contributor

@hoodmane hoodmane Jan 16, 2026

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)

Copy link
Contributor

@ryanking13 ryanking13 left a 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");
Copy link
Contributor

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?

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.

4 participants