Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions grpc/interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ const (
returnOverhead = 20 * time.Millisecond
meaningfulWorkOverhead = 100 * time.Millisecond
clientRequestTimeKey = "client-request-time"
userAgentKey = "acme-client-user-agent"
// We use the "-bin" suffix to tell grpc's metadata package not to require the user-agent
// be printable ASCII. It's rare, but ACME clients can send non-ASCII user-agents.
// Remove `userAgentKey` once this has been deployed.
userAgentKey2 = "acme-client-user-agent-bin"
userAgentKey = "acme-client-user-agent-bin"
)

type serverInterceptor interface {
Expand Down Expand Up @@ -95,9 +93,7 @@ func (smi *serverMetadataInterceptor) Unary(
return nil, err
}
}
if len(md[userAgentKey2]) > 0 {
ctx = web.WithUserAgent(ctx, md[userAgentKey2][0])
} else if len(md[userAgentKey]) > 0 {
if len(md[userAgentKey]) > 0 {
ctx = web.WithUserAgent(ctx, md[userAgentKey][0])
}
}
Expand Down Expand Up @@ -281,8 +277,6 @@ func (cmi *clientMetadataInterceptor) Unary(
// Create a grpc/metadata.Metadata instance for the request metadata.
reqMD := metadata.New(map[string]string{
clientRequestTimeKey: nowTS,
userAgentKey: web.UserAgent(ctx),
userAgentKey2: web.UserAgent(ctx),
Comment on lines -284 to -285

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't be removing both keys here, only remove the line with userAgentKey2. Same comment below.

})
// Configure the localCtx with the metadata so it gets sent along in the request
localCtx = metadata.NewOutgoingContext(localCtx, reqMD)
Expand Down Expand Up @@ -390,8 +384,6 @@ func (cmi *clientMetadataInterceptor) Stream(
// Initialize it with the request time.
reqMD := metadata.New(map[string]string{
clientRequestTimeKey: nowTS,
userAgentKey: web.UserAgent(ctx),
userAgentKey2: web.UserAgent(ctx),
})
// Configure the localCtx with the metadata so it gets sent along in the request
localCtx = metadata.NewOutgoingContext(localCtx, reqMD)
Expand Down
Loading