Include -H headers on server reflection
This commit is contained in:
parent
db940a7d51
commit
ddf962216e
|
|
@ -54,9 +54,6 @@ var (
|
||||||
read from stdin. For calls that accept a stream of requests, the
|
read from stdin. For calls that accept a stream of requests, the
|
||||||
contents should include all such request messages concatenated together
|
contents should include all such request messages concatenated together
|
||||||
(optionally separated by whitespace).`)
|
(optionally separated by whitespace).`)
|
||||||
reflectWithHeaders = flag.Bool("reflect-with-headers", false,
|
|
||||||
`Include headers provided with -H when performing reflection calls
|
|
||||||
against a remote server.`)
|
|
||||||
connectTimeout = flag.String("connect-timeout", "",
|
connectTimeout = flag.String("connect-timeout", "",
|
||||||
`The maximum time, in seconds, to wait for connection to be established.
|
`The maximum time, in seconds, to wait for connection to be established.
|
||||||
Defaults to 10 seconds.`)
|
Defaults to 10 seconds.`)
|
||||||
|
|
@ -76,9 +73,11 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// TODO: Allow separate headers for relflection/invocation
|
||||||
flag.Var(&addlHeaders, "H",
|
flag.Var(&addlHeaders, "H",
|
||||||
`Additional request headers in 'name: value' format. May specify more
|
`Additional request headers in 'name: value' format. May specify more
|
||||||
than one via multiple -H flags.`)
|
than one via multiple -H flags. These headers will also be included in
|
||||||
|
reflection requests to a server.`)
|
||||||
flag.Var(&protoset, "protoset",
|
flag.Var(&protoset, "protoset",
|
||||||
`The name of a file containing an encoded FileDescriptorSet. This file's
|
`The name of a file containing an encoded FileDescriptorSet. This file's
|
||||||
contents will be used to determine the RPC schema instead of querying
|
contents will be used to determine the RPC schema instead of querying
|
||||||
|
|
@ -232,11 +231,8 @@ func main() {
|
||||||
fail(err, "Failed to process proto descriptor sets")
|
fail(err, "Failed to process proto descriptor sets")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
refCtx := ctx
|
md := grpcurl.MetadataFromHeaders(addlHeaders)
|
||||||
if *reflectWithHeaders {
|
refCtx := metadata.NewOutgoingContext(ctx, md)
|
||||||
md := grpcurl.MetadataFromHeaders(addlHeaders)
|
|
||||||
refCtx = metadata.NewOutgoingContext(ctx, md)
|
|
||||||
}
|
|
||||||
cc = dial()
|
cc = dial()
|
||||||
refClient = grpcreflect.NewClient(refCtx, reflectpb.NewServerReflectionClient(cc))
|
refClient = grpcreflect.NewClient(refCtx, reflectpb.NewServerReflectionClient(cc))
|
||||||
descSource = grpcurl.DescriptorSourceFromServer(ctx, refClient)
|
descSource = grpcurl.DescriptorSourceFromServer(ctx, refClient)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue