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

Stop truncating multi-value headers #1691

Closed
timkelty opened this issue Nov 12, 2023 · 2 comments · Fixed by #1730
Closed

Stop truncating multi-value headers #1691

timkelty opened this issue Nov 12, 2023 · 2 comments · Fixed by #1730

Comments

@timkelty
Copy link

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html

Format 2.0 doesn't have multiValueHeaders or multiValueQueryStringParameters fields. Duplicate headers are combined with commas and included in the headers field

As API Gateway 2.0 doesn't support multiValueHeaders – Bref takes only the last value.

It seems like a better solution to not do anything and allow APIG to join them with a comma – at least that way there isn't any data loss, and your app can adjust to get the values.

Related: #818

@mnapoli
Copy link
Member

mnapoli commented Nov 14, 2023

Hi, I'm not sure I understand everything.

Could you clarify with:

  • what you expect to happen
  • what happens instead

Thanks!

@timkelty
Copy link
Author

timkelty commented Nov 15, 2023

What currently happens

Given a response with multi-value headers (2 unique headers with the same name), Bref will only keep the last header: https://github.com/brefphp/bref/blob/master/src/Event/Http/HttpResponse.php#L37

Eg, given

x-foo: bar
x-foo: baz

The APIG response will be constructed with only x-foo: baz

What I expect to happen

I expect headers with duplicate names to be joined with a ,, which is API Gateway v2's default behavior:

So, x-foo: bar,baz

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html

Format 2.0 doesn't have multiValueHeaders or multiValueQueryStringParameters fields. Duplicate headers are combined with commas and included in the headers field

So, it seems like Bref shouldn't do any special handling for these headers, and instead rely on APIG's default handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants