/
proto_http.go
47 lines (40 loc) · 1.14 KB
/
proto_http.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package ably
import (
"fmt"
"runtime"
"strings"
)
// constants for rsc7
const (
ablyProtocolVersionHeader = "X-Ably-Version"
ablyErrorCodeHeader = "X-Ably-Errorcode"
ablyErrorMessageHeader = "X-Ably-Errormessage"
clientLibraryVersion = "1.2.17"
clientRuntimeName = "go"
ablyProtocolVersion = "2" // CSV2
ablyClientIDHeader = "X-Ably-ClientId"
hostHeader = "Host"
ablyAgentHeader = "Ably-Agent" // RSC7d
ablySDKIdentifier = "ably-go/" + clientLibraryVersion // RSC7d1
)
var goRuntimeIdentifier = func() string {
return fmt.Sprintf("%s/%s", clientRuntimeName, runtime.Version()[2:])
}()
func ablyAgentIdentifier(agents map[string]string) string {
identifiers := []string{
ablySDKIdentifier,
goRuntimeIdentifier,
}
osIdentifier := goOSIdentifier()
if !empty(osIdentifier) {
identifiers = append(identifiers, osIdentifier)
}
for product, version := range agents {
if empty(version) {
identifiers = append(identifiers, product)
} else {
identifiers = append(identifiers, product+"/"+version)
}
}
return strings.Join(identifiers, " ")
}