Skip to content

Conversation

@karlseguin
Copy link
Collaborator

chromedb doesn't support duplicate header names. Although servers will send this (e.g. Cache-Control: public\r\nCache-Control: max-age=60\r\n), Chrome seems to join them with a "\n". So we do the same.

A note on curl_easy_nextheader, which this code ultimately uses to iterate and collect the headers. The documentation says:

Applications must copy the data if they want it to survive subsequent API
calls or the life-time of the easy handle.

As-is, I'd understand this to mean that a given header name/value is only valid until any API call, including another call to curl_easy_nextheader. So, from this comment, we should be duping the name/value. But we don't. Why? Because, despite the note in the documentation, this doesn't appear to be how it actually works, nor does it really make sense. If it's just a linked list, there's no reason curl_easy_nextheader should invalidate previous results. I'm guessing this is just a general lack of guarantee libcurl is willing to make re lifetimes.

#966

chromedb doesn't support duplicate header names. Although servers _will_ send
this (e.g. Cache-Control: public\r\nCache-Control: max-age=60\r\n), Chrome
seems to join them with a "\n". So we do the same.

A note on curl_easy_nextheader, which this code ultimately uses to iterate
and collect the headers. The documentation says:

    Applications must copy the data if they want it to survive subsequent API
    calls or the life-time of the easy handle.

As-is, I'd understand this to mean that a given header name/value is only
valid until any API call, including another call to curl_easy_nextheader. So,
from this comment, we _should_ be duping the name/value. But we don't. Why?
Because, despite the note in the documentation, this doesn't appear to be how
it actually works, nor does it really make sense. If it's just a linked list,
there's no reason curl_easy_nextheader should invalidate previous results. I'm
guessing this is just a general lack of guarantee libcurl is willing to make re
lifetimes.

#966
@krichprollsch krichprollsch merged commit 3316f2f into main Aug 25, 2025
10 checks passed
@krichprollsch krichprollsch deleted the normalize_cdp_response_headers branch August 25, 2025 07:31
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants