Skip to content

Add metadata retrieved from the context to the user agent when a new HTTP client is created #2789

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

Merged
merged 6 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
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
Next Next commit
Set the extra user agent when a new rpc instance is created
  • Loading branch information
MatteoPologruto committed Jan 22, 2025
commit b7b539986c96593b9b3311ffd8f58e1cb462d7ce
18 changes: 18 additions & 0 deletions commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
var userAgent string
if md, ok := metadata.FromIncomingContext(ctx); ok {
userAgent = strings.Join(md.Get("user-agent"), " ")
if userAgent != "" {
// s.SettingsGetValue() returns an error if the key does not exist and for this reason we are accessing
// network.user_agent_ext directly from s.settings.ExtraUserAgent() to set it
if s.settings.ExtraUserAgent() == "" {
if strings.Contains(userAgent, "arduino-ide/2") {
// needed for analytics purposes
userAgent = userAgent + " daemon"
}
_, err := s.SettingsSetValue(ctx, &rpc.SettingsSetValueRequest{
Key: "network.user_agent_ext",
ValueFormat: "cli",
EncodedValue: userAgent,
})
if err != nil {
return nil, err
}
}
}
}

// Setup downloads directory
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy