question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The headers with same key are overwritten

See original GitHub issue

Starlette responses adds cookies as headers with the same key. self.raw_headers.append((b"set-cookie", cookie_val.encode("latin-1")))

In your middleware handle outgoing request over writes the same key with only the last value.

        async def handle_outgoing_request(message: Message) -> None:
            if message['type'] == 'http.response.start':
                headers = {k.decode(): v.decode() for (k, v) in message['headers']}
                headers[self.header_name] = correlation_id.get()
                headers['Access-Control-Expose-Headers'] = self.header_name
                response_headers = Headers(headers=headers)
                message['headers'] = response_headers.raw
            await send(message)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
lakshaytharejacommented, Mar 18, 2022

https://github.com/snok/asgi-correlation-id/pull/25

0reactions
sondrelgcommented, Mar 21, 2022

v1.1.3 should be out within the next minute, so will consider this closed 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

23. Overwrite values of headers with same name in ... - YouTube
Hi All, Rest Assured will by default merge values of headers with the same name which I have shown in the last video....
Read more >
HTTP response headers with the same key are not processed ...
HTTP response headers with the same key are not processed properly. [The expected behaviour is that the values of the identical keys are...
Read more >
HttpRequestMessage multiple custom headers overwriting ...
It seems the "Accept" header is reserved. No matter what value I tried to assign to it a FormatException was thrown.
Read more >
Luks header overwritten with dd - Super User
I'm really sorry, but the LUKS header contains the passphrase-encrypted key(s) which unlock everything else. Without a backup copy of the header ......
Read more >
Headers.set() - Web APIs - MDN Web Docs - Mozilla
overwrites the existing value with the new one, whereas Headers. append appends the new value to the end of the set of values....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found