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

Remove HTTP/2 Push Promise support since Plug is deprecating it #33

Merged
merged 5 commits into from Oct 4, 2022

Conversation

mtrudel
Copy link
Owner

@mtrudel mtrudel commented Oct 3, 2022

See elixir-plug/plug@cd258e7

@moogle19 you've had a lot of eyes here lately; care to give this a once over?

@moogle19
Copy link
Contributor

moogle19 commented Oct 4, 2022

Can't we get rid of the PushPromise frame altogether and just handle it as an Unknown frame?

Alternatively if you want to keep the frame, it can be an empty struct since the fields aren't used anyway (as far as I can see). If we want to ignore invalid PushPromise frames (zero stream_id and invalid padding length) the deserialization can also be skipped and Frame.deserialize/2 can return the empty PushPromise struct directly.

WDYT?

Edit: And the Stream.stream_id_is_valid_server/1 is reported as unused by the compiler.

@mtrudel
Copy link
Owner Author

mtrudel commented Oct 4, 2022

Can't we get rid of the PushPromise frame altogether and just handle it as an Unknown frame?

Sadly we cannot, since a number of tests in h2spec require us to handle push frames in a specific way (even if we don't support them). We can drop the deserialization down to a single error clause though, since all of the failure cases in the spec resolve down to the same error (protocol error, close connection).

We will need to keep the deserialize function around, but no longer need to have a struct definition for PushPromise.

Edit: And the Stream.stream_id_is_valid_server/1 is reported as unused by the compiler.

✅ thanks!

@mtrudel
Copy link
Owner Author

mtrudel commented Oct 4, 2022

Updated

Copy link
Contributor

@moogle19 moogle19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one little thing.
Otherwise it looks good!

@@ -33,10 +33,10 @@ defmodule Bandit.HTTP2.Frame.Settings do
{:cont, {:ok, %{acc | header_table_size: value}}}

{:ok, {0x02, 0x01}}, {:ok, acc} ->
{:cont, {:ok, %{acc | enable_push: true}}}
{:cont, {:ok, acc}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove these cases all together (and ignore invalid enable_push values)?
h2spec seems fine with it.

Otherwise group the valid cases to {:ok, {0x02, val}}, {:ok, acc} when val in [0x00, 0x01] ->?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep the handling, even if h2spec doesn't complain. No sense in walking back strict conformance.

Updated to use a when clause, as suggested

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe use {:ok, {0x02, value}}, {:ok, _acc} when value not in [0x00, 0x01] on the error case and drop the noop case?

@mtrudel mtrudel merged commit f97c0b8 into main Oct 4, 2022
@mtrudel mtrudel deleted the deprecate_push branch October 4, 2022 15:19
mtrudel added a commit that referenced this pull request Oct 10, 2023
This should have actually come out as part of #33 but was missed
mtrudel added a commit that referenced this pull request Oct 10, 2023
This should have actually come out as part of #33 but was missed
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

Successfully merging this pull request may close these issues.

None yet

2 participants