mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 11:46:40 +00:00
Tweak the User-Agent a bit (#1153)
* [bugfix] Use AccountDomain for user agent By using the account domain we can pinpoint the source of the request more accurately when looking at the User-Agent header. * [chore] Align user-agent header with spec Based on RFC 7231, our User-Agent header doesn't quite match. It seems to always want Name [/ Version] pairs, with comments in parenthesis and multiple comments separated by a semicolon. Align our UA with that, using application name first by itself in case someone has customised it with the source instance in a comment. Follow that up with gotosocial/<version> and a comment pointing at the source code. This also drops the mention of gofed/activity since a fork is in use.
This commit is contained in:
parent
746f3fa4e6
commit
d6f4d196c9
|
@ -59,7 +59,8 @@ type controller struct {
|
||||||
// NewController returns an implementation of the Controller interface for creating new transports
|
// NewController returns an implementation of the Controller interface for creating new transports
|
||||||
func NewController(db db.DB, federatingDB federatingdb.DB, clock pub.Clock, client pub.HttpClient) Controller {
|
func NewController(db db.DB, federatingDB federatingdb.DB, clock pub.Clock, client pub.HttpClient) Controller {
|
||||||
applicationName := config.GetApplicationName()
|
applicationName := config.GetApplicationName()
|
||||||
host := config.GetHost()
|
host := config.GetAccountDomain()
|
||||||
|
proto := config.GetProtocol()
|
||||||
version := config.GetSoftwareVersion()
|
version := config.GetSoftwareVersion()
|
||||||
|
|
||||||
c := &controller{
|
c := &controller{
|
||||||
|
@ -69,7 +70,7 @@ func NewController(db db.DB, federatingDB federatingdb.DB, clock pub.Clock, clie
|
||||||
client: client,
|
client: client,
|
||||||
trspCache: cache.New[string, *transport](0, 100, 0),
|
trspCache: cache.New[string, *transport](0, 100, 0),
|
||||||
badHosts: cache.New[string, struct{}](0, 1000, 0),
|
badHosts: cache.New[string, struct{}](0, 1000, 0),
|
||||||
userAgent: fmt.Sprintf("%s; %s (gofed/activity gotosocial-%s)", applicationName, host, version),
|
userAgent: fmt.Sprintf("%s (+%s://%s) gotosocial/%s", applicationName, proto, host, version),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transport cache has TTL=1hr freq=1min
|
// Transport cache has TTL=1hr freq=1min
|
||||||
|
|
Loading…
Reference in a new issue