From 9e61e080659b42d50b9f355cee5a65fc4396d580 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Tue, 7 Feb 2017 19:31:03 +0000 Subject: [PATCH] =?UTF-8?q?User-Agent=20"Python-gRPC-"=20=E2=86=92=20"grpc?= =?UTF-8?q?-python/"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This brings gRPC Python into conformance with the recommendation in https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md. --- src/python/grpcio/grpc/_channel.py | 2 +- src/python/grpcio_tests/tests/unit/_metadata_test.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 691e96a3228..a1ac80651e5 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -39,7 +39,7 @@ from grpc import _grpcio_metadata from grpc._cython import cygrpc from grpc.framework.foundation import callable_util -_USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__) +_USER_AGENT = 'grpc-python/{}'.format(_grpcio_metadata.__version__) _EMPTY_FLAGS = 0 _INFINITE_FUTURE = cygrpc.Timespec(float('+inf')) diff --git a/src/python/grpcio_tests/tests/unit/_metadata_test.py b/src/python/grpcio_tests/tests/unit/_metadata_test.py index 53fe7ba8aa5..035d87e3cf4 100644 --- a/src/python/grpcio_tests/tests/unit/_metadata_test.py +++ b/src/python/grpcio_tests/tests/unit/_metadata_test.py @@ -32,7 +32,7 @@ import unittest import weakref import grpc -from grpc import _grpcio_metadata +from grpc import _channel from grpc.framework.foundation import logging_pool from tests.unit import test_common @@ -49,8 +49,6 @@ _UNARY_STREAM = '/test/UnaryStream' _STREAM_UNARY = '/test/StreamUnary' _STREAM_STREAM = '/test/StreamStream' -_USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__) - _CLIENT_METADATA = (('client-md-key', 'client-md-key'), ('client-md-key-bin', b'\x00\x01')) @@ -76,7 +74,7 @@ def validate_client_metadata(test, servicer_context): _CLIENT_METADATA, servicer_context.invocation_metadata())) test.assertTrue( user_agent(servicer_context.invocation_metadata()) - .startswith('primary-agent ' + _USER_AGENT)) + .startswith('primary-agent ' + _channel._USER_AGENT)) test.assertTrue( user_agent(servicer_context.invocation_metadata()) .endswith('secondary-agent'))