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

make :authority propagate to MD #683

Merged
merged 3 commits into from
Jun 2, 2016

Conversation

mwitkow
Copy link
Contributor

@mwitkow mwitkow commented May 16, 2016

Fixes #457

This is incredibly useful to decide, e.g. on what behaviour to have. E.g. you can enable certain features based on the domain used by the caller.

  • Added tests asserting :authority is there.
  • Fixed a problem where users could provide an HTTP restricted field (such as :authority) mid-way, causing the stream to fail. These are now filtered out.
  • Fixed Compression is flaky when using Metadata in call #686 along the way, since it couldn't deal with metadata.

@@ -162,7 +173,7 @@ func (d *decodeState) processHeaderField(f hpack.HeaderField) {
case ":path":
d.method = f.Value
default:
if !isReservedHeader(f.Name) {
if !isReservedHeader(f.Name) || isWhitelistedHttp2Header(f.Name) {
Copy link
Contributor

@tamird tamird May 16, 2016

Choose a reason for hiding this comment

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

@isn't !isReservedHeader(":authority") already true?

EDIT: nope, disregard

@mwitkow
Copy link
Contributor Author

mwitkow commented May 16, 2016

@iamqizhao thoughts on enabling authority access in MD?

@iamqizhao
Copy link
Contributor

Sounds good to me.

I am not sure how comes the test failure. Can you verify if it is from your change?

@mwitkow
Copy link
Contributor Author

mwitkow commented May 17, 2016

@iamqizhao can you help with the errors?
end2end_test.go:1685: TestService/UnaryCall(_, _) = _, rpc error: code = 13 desc = pseudo header field after regular, want _, <nil>

This seems to be an error from http/Framer.ReadFrame(). However, I fail to see how an decodeState.mdata field would be parsed to framer.Reader. Do the end2end tests pass teh same context to responses and back to clients?

@mwitkow
Copy link
Contributor Author

mwitkow commented May 17, 2016

@iamqizhao, did some investigation. Apparently: pseudo header field after regular can happen whenever users specify a reserved http2 field (e.g. :authority). This breaks every client gRPC says, so I added code to guard against that.

The reason why the test was failing, was because all the end2end tests forward the received context (and thus the new :authority field).

@mwitkow
Copy link
Contributor Author

mwitkow commented May 17, 2016

Also it seems that TestCompressOK test is flaky. It seems that if you provide Metadata to a compress call, it will fail to call

    if s.sendCompress != "" {
        fmt.Printf("Calling send compress!\n")
        t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-encoding", Value: s.sendCompress})
    }

never gets called, hence the filtering of reserved fields fails.

#686

@mwitkow mwitkow force-pushed the feature/propagate-authority branch from 610f7fb to 1ef2c52 Compare May 17, 2016 13:35
@@ -127,6 +127,17 @@ func isReservedHeader(hdr string) bool {
}
}

// isWhitelistedHttp2Header checks whether hdr belongs to HTTP2 headers
// that should be propagated into metadata visible to users.
func isWhitelistedHttp2Header(hdr string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/isWhitelistedHttp2Header/isWhitelistedPseudoHeader/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@iamqizhao iamqizhao merged commit aecdcca into grpc:master Jun 2, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants