Merge pull request #257 from iamqizhao/master
Invert User-Agent order so application-provided string comes first
This commit is contained in:
@ -62,7 +62,7 @@ var (
|
||||
"key1": "value1",
|
||||
"key2": "value2",
|
||||
}
|
||||
testAppUA = "myApp/1.0"
|
||||
testAppUA = "myApp1/1.0 myApp2/0.9"
|
||||
)
|
||||
|
||||
type testServer struct {
|
||||
|
@ -161,7 +161,7 @@ func newHTTP2Client(addr string, opts *ConnectOptions) (_ ClientTransport, err e
|
||||
}
|
||||
ua := primaryUA
|
||||
if opts.UserAgent != "" {
|
||||
ua += " " + opts.UserAgent
|
||||
ua = opts.UserAgent + " " + ua
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
t := &http2Client{
|
||||
|
@ -164,13 +164,13 @@ func newHPACKDecoder() *hpackDecoder {
|
||||
default:
|
||||
if !isReservedHeader(f.Name) {
|
||||
if f.Name == "user-agent" {
|
||||
str := strings.Split(f.Value, " ")
|
||||
if len(str) <= 1 {
|
||||
i := strings.LastIndex(f.Value, " ")
|
||||
if i == -1 {
|
||||
// There is no application user agent string being set.
|
||||
return
|
||||
}
|
||||
// Extract the application user agent string.
|
||||
f.Value = str[1]
|
||||
f.Value = f.Value[:i]
|
||||
}
|
||||
if d.state.mdata == nil {
|
||||
d.state.mdata = make(map[string]string)
|
||||
|
Reference in New Issue
Block a user