Skip to content

HTTP2 authority header is not set to resolver.Address.ServerName (?) #4516

Closed
@fho

Description

@fho

Hello,

according to the godoc and this comment,
the HTTP2 authority header field is set to the resolver.Address.ServerName value that is returned by a resolver.
I can not reproduce this with grpc-go 1.38.0 nor with v1.39.0-dev.0.20210603231021-5c164e2b8f22.

If I understand the code correctly, the http2 authority header is set here to cc.authority and cc.authority is set depending on the parameters of DialContext.
Therefore HTTP2 authority field is never set to resolver.Address.ServerName.

Do I understand something wrong or is this a bug?

(When I set a custom authority via the grpc.WithAuthority() dial option, the authority is set accordingly.)

Some more context, why this became an issue for me:
I'm maintaining a consul grpc-go resolver.
The resolver accepts a custom URL via grpc.Dial() in the format: consul://[<consul-server>]/<serviceName>[?<OPT>[&<OPT>]...].
It queries a consul-server for the addresses of serviceName and returns it addresses.
The resolver was only setting the resolver.Address.Addr, not resolver.Address.ServerName.
When the GRPC-Requests are send out the HTTP2 authority header field is set to a bogus value, to the <serviceName>[?<OPT>[&<OPT>]...] part of the URL. This part is parsed here as authority.
This was not a problem when communicating with grpc-go servers, they seem to ignore the bogus authority value.
When communicating with grpc-server written in Node based on grpc-js 1.3.2, this caused that GRPC-Calls fail with a PROTOCOL_ERROR.
Setting resolver.Address.ServerName in my resolver to the same then resolver.Address.Addr does not have any effect.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions