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

Why all headers values are split as they are comma separated in EventToRequest? #171

Open
arabello opened this issue Apr 2, 2023 · 1 comment

Comments

@arabello
Copy link

arabello commented Apr 2, 2023

I had an issue while integrating a custom header containing a comma , caused by RequestAccessorV2.EventToRequestWithContext: the request returned has the custom header value as an array of two strings (original value split into two parts) instead of an array of a single element (the entire value with the comma).

Looking at the code, it seems that the RequestAccessor splits headers values treating them as they all are comma-separated.

for headerKey, headerValue := range req.Headers {
    for _, val := range strings.Split(headerValue, ",") {
        httpRequest.Header.Add(headerKey, strings.Trim(val, " "))
    }
}

Why so? If an header is not defined as comma-separated no splitting strategy should occur, shouldn't it? What am I missing?

Moreover, why this behavior differs from the RequestAccessor (V1)?

@advdv
Copy link

advdv commented Aug 3, 2024

We're running into this issue as well. In our case it is the Access-Control-Request-Headers, it is split before it reaches the CORS middleware: https://github.com/rs/cors/blob/1562b1715b353146f279ff7d445b7412e0f1a842/cors.go#L367. The middleware expects it to not be a multi-value and only looks the first element.

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

No branches or pull requests

2 participants