User-Agent "Python-gRPC-" → "grpc-python/"

This brings gRPC Python into conformance with the recommendation in
https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md.
pull/9625/head
Nathaniel Manista 8 years ago
parent 5b3f341e2e
commit 9e61e08065
  1. 2
      src/python/grpcio/grpc/_channel.py
  2. 6
      src/python/grpcio_tests/tests/unit/_metadata_test.py

@ -39,7 +39,7 @@ from grpc import _grpcio_metadata
from grpc._cython import cygrpc from grpc._cython import cygrpc
from grpc.framework.foundation import callable_util 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 _EMPTY_FLAGS = 0
_INFINITE_FUTURE = cygrpc.Timespec(float('+inf')) _INFINITE_FUTURE = cygrpc.Timespec(float('+inf'))

@ -32,7 +32,7 @@ import unittest
import weakref import weakref
import grpc import grpc
from grpc import _grpcio_metadata from grpc import _channel
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
from tests.unit import test_common from tests.unit import test_common
@ -49,8 +49,6 @@ _UNARY_STREAM = '/test/UnaryStream'
_STREAM_UNARY = '/test/StreamUnary' _STREAM_UNARY = '/test/StreamUnary'
_STREAM_STREAM = '/test/StreamStream' _STREAM_STREAM = '/test/StreamStream'
_USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__)
_CLIENT_METADATA = (('client-md-key', 'client-md-key'), _CLIENT_METADATA = (('client-md-key', 'client-md-key'),
('client-md-key-bin', b'\x00\x01')) ('client-md-key-bin', b'\x00\x01'))
@ -76,7 +74,7 @@ def validate_client_metadata(test, servicer_context):
_CLIENT_METADATA, servicer_context.invocation_metadata())) _CLIENT_METADATA, servicer_context.invocation_metadata()))
test.assertTrue( test.assertTrue(
user_agent(servicer_context.invocation_metadata()) user_agent(servicer_context.invocation_metadata())
.startswith('primary-agent ' + _USER_AGENT)) .startswith('primary-agent ' + _channel._USER_AGENT))
test.assertTrue( test.assertTrue(
user_agent(servicer_context.invocation_metadata()) user_agent(servicer_context.invocation_metadata())
.endswith('secondary-agent')) .endswith('secondary-agent'))

Loading…
Cancel
Save