-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP User-Agent string-building no longer supports comments #2198
Comments
This is definitely a side effect of a recent User-Agent change. Note that for the time being you can reclaim this behavior through a build-phase middleware: import (
"context"
"fmt"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
type userAgentAppender struct {
v string
}
func (*userAgentAppender) ID() string {
return "userAgentAppender"
}
func (m *userAgentAppender) HandleBuild(ctx context.Context, in middleware.BuildInput, next middleware.BuildHandler) (
out middleware.BuildOutput, metadata middleware.Metadata, err error,
) {
r, ok := in.Request.(*smithyhttp.Request)
if !ok {
return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
}
if ua := r.Header.Get("user-agent"); ua != "" {
r.Header.Set("user-agent", fmt.Sprintf("%s %s", ua, m.v))
}
return next.HandleBuild(ctx, in)
}
func withUserAgentAppender(v string) func(*middleware.Stack) error {
return func(stack *middleware.Stack) error {
return stack.Build.Add(&userAgentAppender{v: v}, middleware.After)
}
} EDIT: added missing imports |
Thanks, the workaround works |
Ive created #2202 to re-add this through the new The For that reason I believe a new, separate API (which can also apply to any header generically) was the most sensible way forward here. |
Hi @gdavison -- apologies for dropping the ball on this. I've just now re-spawned the PR in smithy-go, we decided to expose it there instead back in July and it never happened. |
Fixed by aws/smithy-go#461. This will be available in the next release. |
|
Describe the bug
In the HTTP spec, User-Agent strings support a combination of
product
s andcomment
s. Acomment
is text contained within parentheses.Prior to
aws-sdk-go-v2
v1.19.0, comments could be added usingExpected Behavior
I expected
to continue working.
For example, a comment with the text
this is a comment
should be included in the User-Agent string asCurrent Behavior
Several characters in the comment are replaced by
-
. For example, a comment with the textthis is a comment
is included in the User-Agent string asinstead of
Reproduction Steps
Generate an HTTP User-Agent string after setting
Possible Solution
One of two solutions:
Directly support HTTP User-Agent comment with a function like
middleware.AddUserAgentComment()
Update the escaping rules to not escape keys that match the
comment
pattern defined in the HTTP specAdditional Information/Context
No response
AWS Go SDK V2 Module Versions Used
aws-sdk-go-v2 v1.19.0
Compiler and Version used
go version go1.20.3 darwin/arm64
Operating System and version
macOS 12.6.7
The text was updated successfully, but these errors were encountered: