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

Reject responses that have explicit set-cookie #1619

Closed
essen opened this issue Nov 7, 2023 · 7 comments
Closed

Reject responses that have explicit set-cookie #1619

essen opened this issue Nov 7, 2023 · 7 comments
Milestone

Comments

@essen
Copy link
Member

essen commented Nov 7, 2023

This causes confusion otherwise. See #1483 (comment)

We want users to call set_resp_cookie or to manually set the raw resp_cookies value in the Req. A function to do that may be welcome. This is mainly useful for proxies though so not sure how much we should do.

@geeksilva97
Copy link
Contributor

I am looking for issues in Erlang to practice more. Would you say I could pick this one?

@essen
Copy link
Member Author

essen commented Jan 5, 2024

Hello @geeksilva97 sorry I had not received an email following your comment, guess it got lost. Yes it would be a good choice. Basically the functions set_resp_header, set_resp_headers, inform, reply, stream_reply and stream_trailers should fail if the headers given in argument contain set-cookie.

@geeksilva97
Copy link
Contributor

Thank you, @essen . Will give it try, starting tomorrow.

@geeksilva97
Copy link
Contributor

geeksilva97 commented Jan 8, 2024

Just a confirmation, @essen . Should I throw an error? If so, are you expecting anything special?

I was naively thinking of something like

set_resp_header(<<"set-cookie">>, _, _) ->
    throw({invalid_header_name, <<"set-cookie">>});

@essen
Copy link
Member Author

essen commented Jan 9, 2024

Please use something of the form:

exit({response_error, invalid_header,
    'The set-cookie header is special and must be set using cowboy_req:set_resp_cookie/3,4.'})

See a40bab8 for a more extensive example.

@geeksilva97
Copy link
Contributor

Please use something of the form:

exit({response_error, invalid_header,
    'The set-cookie header is special and must be set using cowboy_req:set_resp_cookie/3,4.'})

See a40bab8 for a more extensive example.

Thank you. Will do.

@essen
Copy link
Member Author

essen commented Jan 16, 2024

Done. Closing, thank you!

@essen essen closed this as completed Jan 16, 2024
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