mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-24 09:39:39 +00:00
ipn/ipnlocal: proxy gRPC requests over h2c if needed. (#9847)
Updates userspace proxy to detect plaintext grpc requests using the preconfigured host prefix and request's content type header and ensure that these will be proxied over h2c. Updates tailscale/tailscale#9725 Signed-off-by: Irbe Krumina <irbe@tailscale.com>
This commit is contained in:
@@ -587,3 +587,39 @@ func TestServeFileOrDirectory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_isGRPCContentType(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
contentType string
|
||||
want bool
|
||||
}{
|
||||
"application/grpc": {
|
||||
contentType: "application/grpc",
|
||||
want: true,
|
||||
},
|
||||
"application/grpc;": {
|
||||
contentType: "application/grpc;",
|
||||
want: true,
|
||||
},
|
||||
"application/grpc+": {
|
||||
contentType: "application/grpc+",
|
||||
want: true,
|
||||
},
|
||||
"application/grpcfoobar": {
|
||||
contentType: "application/grpcfoobar",
|
||||
},
|
||||
"application/text": {
|
||||
contentType: "application/text",
|
||||
},
|
||||
"foobar": {
|
||||
contentType: "foobar",
|
||||
},
|
||||
}
|
||||
for name, scenario := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
if got := isGRPCContentType(scenario.contentType); got != scenario.want {
|
||||
t.Errorf("test case %s failed, isGRPCContentType() = %v, want %v", name, got, scenario.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user