|
65 | 65 | }
|
66 | 66 | grpcTimeoutUnitLookup = make(map[byte]time.Duration)
|
67 | 67 | errTrailersWithoutGRPCStatus = fmt.Errorf("gRPC protocol error: no %s trailer", grpcHeaderStatus)
|
| 68 | + |
| 69 | + // defaultGrpcUserAgent follows |
| 70 | + // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#user-agents: |
| 71 | + // |
| 72 | + // While the protocol does not require a user-agent to function it is recommended |
| 73 | + // that clients provide a structured user-agent string that provides a basic |
| 74 | + // description of the calling library, version & platform to facilitate issue diagnosis |
| 75 | + // in heterogeneous environments. The following structure is recommended to library developers: |
| 76 | + // |
| 77 | + // User-Agent → "grpc-" Language ?("-" Variant) "/" Version ?( " (" *(AdditionalProperty ";") ")" ) |
| 78 | + defaultGrpcUserAgent = fmt.Sprintf("grpc-go-connect/%s (%s)", Version, runtime.Version()) |
68 | 79 | )
|
69 | 80 |
|
70 | 81 | func init() {
|
@@ -227,7 +238,7 @@ func (g *grpcClient) WriteRequestHeader(_ StreamType, header http.Header) {
|
227 | 238 | // We know these header keys are in canonical form, so we can bypass all the
|
228 | 239 | // checks in Header.Set.
|
229 | 240 | if header.Get(headerUserAgent) == "" {
|
230 |
| - header[headerUserAgent] = []string{grpcUserAgent()} |
| 241 | + header[headerUserAgent] = []string{defaultGrpcUserAgent} |
231 | 242 | }
|
232 | 243 | header[headerContentType] = []string{grpcContentTypeFromCodecName(g.web, g.Codec.Name())}
|
233 | 244 | // gRPC handles compression on a per-message basis, so we don't want to
|
@@ -762,19 +773,6 @@ func grpcEncodeTimeout(timeout time.Duration) (string, error) {
|
762 | 773 | return "", errNoTimeout
|
763 | 774 | }
|
764 | 775 |
|
765 |
| -// grpcUserAgent follows |
766 |
| -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#user-agents: |
767 |
| -// |
768 |
| -// While the protocol does not require a user-agent to function it is recommended |
769 |
| -// that clients provide a structured user-agent string that provides a basic |
770 |
| -// description of the calling library, version & platform to facilitate issue diagnosis |
771 |
| -// in heterogeneous environments. The following structure is recommended to library developers: |
772 |
| -// |
773 |
| -// User-Agent → "grpc-" Language ?("-" Variant) "/" Version ?( " (" *(AdditionalProperty ";") ")" ) |
774 |
| -func grpcUserAgent() string { |
775 |
| - return fmt.Sprintf("grpc-go-connect/%s (%s)", Version, runtime.Version()) |
776 |
| -} |
777 |
| - |
778 | 776 | func grpcCodecFromContentType(web bool, contentType string) string {
|
779 | 777 | if (!web && contentType == grpcContentTypeDefault) || (web && contentType == grpcWebContentTypeDefault) {
|
780 | 778 | // implicitly protobuf
|
|
0 commit comments