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

Receiving a PUSH_PROMISE from a client is an error #315

Closed
wants to merge 4 commits into from

Conversation

alexwlchan
Copy link
Contributor

This is explicitly forbidden in the spec (RFC 7540 § 8.2).

A client cannot push. Thus, servers MUST treat the receipt of a
PUSH_PROMISE frame as a connection error (Section 5.4.1) of type
PROTOCOL_ERROR.

In practice hyper-h2 was already raising a ProtocolError, because
local_settings.enable_push is False for servers. This commit:

  • Tweaks the error message to make it clear that receiving it from
    the client is important.
  • Add an explicit test case.

This is explicitly forbidden in the spec (RFC 7540 § 8.2).
In practice hyper-h2 was already raising a ProtocolError, because
local_settings.enable_push is False for servers.  This commit:

* Tweaks the error message to make it clear that receiving it from
  the client is important.
* Add an explicit test case.
Copy link
Member

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Need to change the test.

expected_frame = frame_factory.build_goaway_frame(
1, h2.errors.ErrorCodes.PROTOCOL_ERROR
)
assert c.data_to_send() == expected_frame.serialize()
Copy link
Member

Choose a reason for hiding this comment

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

Running this on my machine shows that this test would have passed before the code change above. Can you check the exception message, which is the substantive part of this change?

Copy link
Contributor Author

@alexwlchan alexwlchan Sep 19, 2016

Choose a reason for hiding this comment

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

The test now checks the exception message.

Copy link
Member

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

So, I have a question about whether we should do this, or whether for performance reasons we should just only do #316.

# A client cannot push - RFC 7540 § 8.2
if not self.config.client_side:
raise ProtocolError("Received pushed stream from a client")

if not self.local_settings.enable_push:
raise ProtocolError("Received pushed stream")
Copy link
Member

Choose a reason for hiding this comment

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

So, here's my question: is this worth it? I think, ordinarily, an invalid push would hit this code block here. That means that we'd still raise a ProtocolError. It also means that now, on push promise receipt, we have an extra if test that always fires in order to check for an error that we'll then immediately look for.

Should we consider whether it'd be better to put the new check into this if block? Or, even more aggressively, should we just implement #316? If we implement #316 then, definitionally, a server will be forbidden from setting ENABLE_PUSH to 1 (because we'll tell it not to), which means that all servers will automatically fall into the if block here.

@alexwlchan
Copy link
Contributor Author

Closing due to inactivity (from me).

@alexwlchan alexwlchan closed this Nov 4, 2016
@Kriechi Kriechi deleted the awlc/clients-dont-push branch February 8, 2020 11:25
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.

2 participants