mirror of
https://github.com/rclone/rclone.git
synced 2025-01-22 14:19:56 +01:00
http: add --user-agent option. close #1557
This commit is contained in:
parent
b510c70c1e
commit
2cc9071791
@ -101,6 +101,7 @@ var (
|
|||||||
tpsLimitBurst = IntP("tpslimit-burst", "", 1, "Max burst of transactions for --tpslimit.")
|
tpsLimitBurst = IntP("tpslimit-burst", "", 1, "Max burst of transactions for --tpslimit.")
|
||||||
bindAddr = StringP("bind", "", "", "Local address to bind to for outgoing connections, IPv4, IPv6 or name.")
|
bindAddr = StringP("bind", "", "", "Local address to bind to for outgoing connections, IPv4, IPv6 or name.")
|
||||||
disableFeatures = StringP("disable", "", "", "Disable a comma separated list of features. Use help to see a list.")
|
disableFeatures = StringP("disable", "", "", "Disable a comma separated list of features. Use help to see a list.")
|
||||||
|
userAgent = StringP("user-agent", "", "rclone/"+Version, "Set the user-agent to a specified string. The default is rclone/ version")
|
||||||
logLevel = LogLevelNotice
|
logLevel = LogLevelNotice
|
||||||
statsLogLevel = LogLevelInfo
|
statsLogLevel = LogLevelInfo
|
||||||
bwLimit BwTimetable
|
bwLimit BwTimetable
|
||||||
|
2
fs/fs.go
2
fs/fs.go
@ -28,8 +28,6 @@ const (
|
|||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
var (
|
var (
|
||||||
// UserAgent set in the default Transport
|
|
||||||
UserAgent = "rclone/" + Version
|
|
||||||
// Filesystem registry
|
// Filesystem registry
|
||||||
fsRegistry []*RegInfo
|
fsRegistry []*RegInfo
|
||||||
// ErrorNotFoundInConfigFile is returned by NewFs if not found in config file
|
// ErrorNotFoundInConfigFile is returned by NewFs if not found in config file
|
||||||
|
@ -241,7 +241,7 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Force user agent
|
// Force user agent
|
||||||
req.Header.Set("User-Agent", UserAgent)
|
req.Header.Set("User-Agent", *userAgent)
|
||||||
// Logf request
|
// Logf request
|
||||||
if t.logHeader || t.logBody || t.logAuth {
|
if t.logHeader || t.logBody || t.logAuth {
|
||||||
buf, _ := httputil.DumpRequestOut(req, t.logBody)
|
buf, _ := httputil.DumpRequestOut(req, t.logBody)
|
||||||
|
Loading…
Reference in New Issue
Block a user