elixir-plug / plug

Compose web applications with functions
https://hex.pm/packages/plug
Other
2.88k stars 586 forks source link

Raise error for `put_req_header(conn, "host", value)` #1104

Closed cmcaine closed 2 years ago

cmcaine commented 2 years ago

The host header is overridden by conn.host, so trying to set the header this way will usually not do what the user intended.

cmcaine commented 2 years ago

The error will only be raised during testing, as with the existing validation errors for headers.

josevalim commented 2 years ago

Can you please run mix format as well? Thank you!

josevalim commented 2 years ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart:

cmcaine commented 2 years ago

Given that the host check now happens regardless of whether testing is turned on, I wonder if this commit should be adjusted or the names of the functions changed?

Oh, nevermind, you merged it ;)