如何使用Python gRPC发送自定义标头(元数据)? [英] How to send custom header (metadata) with Python gRPC?
本文介绍了如何使用Python gRPC发送自定义标头(元数据)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何使用Python gRPC发送自定义标头(或元数据).我查看了文档,却找不到任何东西.
I want to know how to send custom header (or metadata) using Python gRPC. I looked into documents and I couldn't find anything.
推荐答案
我想通了阅读代码.您可以向函数调用发送metadata
参数,其中metadata
是2元组的元组:
I figured out reading the code. You can send a metadata
param to the function call, where metadata
is a tuple of 2-tuples:
metadata = (('md-key', 'some value'),
('some-md-key', 'another value'))
response = stub.YourFunctionCall(request=request, metadata=metadata)
这篇关于如何使用Python gRPC发送自定义标头(元数据)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文