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

http2: correct behaviour for enablePush unpack #15167

Closed

Conversation

apapirovski
Copy link
Member

@apapirovski apapirovski commented Sep 3, 2017

So, as per the spec, the only valid values for enablePush should be 0 or 1. nghttp2 already handles this correctly but the JS unpacker exposed to the end-user doesn't. That said, I'm not sure as to the desired behaviour:

  1. Set value to the actual value, validate it's within range (if validation requested) and finally set to Boolean (even if it's not 0 or 1, as long as they didn't request validation which would throw).

  2. Set value to the actual value, validate it's within range (if validation requested) and only set to Boolean if it's 0 or 1, otherwise leave as the actual value for the end-user to handle.

I think we should follow the spec here, at least to the extent that we shouldn't just cast everything to Boolean when validating. If validation is requested then it clearly needs to throw if it's not 0 or 1 (it wasn't doing this before).

But not sure what we actually want to output to the end-user if it's not 0 or 1 and no validation was requested.

And here's the spec btw:

SETTINGS_ENABLE_PUSH (0x2):
This setting can be used to disable server push (Section 8.2). An endpoint MUST NOT send a PUSH_PROMISE frame if it receives this parameter set to a value of 0. An endpoint that has both set this parameter to 0 and had it acknowledged MUST treat the receipt of a PUSH_PROMISE frame as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

The initial value is 1, which indicates that server push is permitted. Any value other than 0 or 1 MUST be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

http2, test

@nodejs-github-bot nodejs-github-bot added the http2 Issues or PRs related to the http2 subsystem. label Sep 3, 2017
@benjamingr
Copy link
Member

I think we should follow the spec here, at least to the extent that we shouldn't just cast everything to Boolean when validating. If validation is requested then it clearly needs to throw if it's not 0 or 1 (it wasn't doing this before).

I'm +1 on that, let's make the right choice while we still can rather than encourage bad code.

@jasnell
Copy link
Member

jasnell commented Sep 6, 2017

@apapirovski
Copy link
Member Author

The failures don't look related to this, or am I missing something? Can we run the CI again maybe?

@jasnell
Copy link
Member

jasnell commented Sep 7, 2017

Oy, all red, but seemingly unrelated... hmmm. trying again https://ci.nodejs.org/job/node-test-commit/12221/

@jasnell
Copy link
Member

jasnell commented Sep 7, 2017

CI is failing on this.

The only valid values for enablePush are 0 and 1. If validation
is requested, we should verify that it wasn't set to another
value rather than casting to Boolean regardless of value.
@apapirovski
Copy link
Member Author

@jasnell as it should be. Yikes. Sorry about that. Fixed now.

@BridgeAR
Copy link
Member

BridgeAR commented Sep 8, 2017

@apapirovski
Copy link
Member Author

apapirovski commented Sep 8, 2017

Bah. Looks like the session timeout test is still flaky occasionally. Will need to look into it. But not related to this PR.

@BridgeAR
Copy link
Member

Landed in c20901a

@BridgeAR BridgeAR closed this Sep 11, 2017
BridgeAR pushed a commit that referenced this pull request Sep 11, 2017
The only valid values for enablePush are 0 and 1. If validation
is requested, we should verify that it wasn't set to another
value rather than casting to Boolean regardless of value.

PR-URL: #15167
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@apapirovski
Copy link
Member Author

Thanks for landing all those PRs, @BridgeAR! Thanks for the reviews everyone.

addaleax pushed a commit to addaleax/node that referenced this pull request Sep 13, 2017
The only valid values for enablePush are 0 and 1. If validation
is requested, we should verify that it wasn't set to another
value rather than casting to Boolean regardless of value.

PR-URL: nodejs#15167
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
jasnell pushed a commit that referenced this pull request Sep 20, 2017
The only valid values for enablePush are 0 and 1. If validation
is requested, we should verify that it wasn't set to another
value rather than casting to Boolean regardless of value.

PR-URL: #15167
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants