I am trying to get header of the gRPC response with the following code, and it doesn't work:
response = stub.GetAccounts(users_pb2.GetAccountsRequest(), metadata=metadata)
header = response.header()
This is what this header looks like in Kreya, I'm trying to get it in python:
Does anyone know how to get the same header in python?
I suspect (! don't know) that you can't access the underlying HTTP/2 (response) headers from the (Python) gRPC client.
You can configure various environment variables that expose underlying details (see gRPC environment variables) and perhaps GRPC_TRACE="http" GRPC_VERBOSITRY="DEBUG".
If the headers were actually gRPC metadata, you can use Python's with_call
and call.initial_metadata
and call.trailing_metadata
as shown in the gRPC metadata example here.