/
const.go
33 lines (28 loc) · 1.13 KB
/
const.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
package surf
import (
"net/http"
"regexp"
)
const Version = "0.0.1"
const (
UserAgent = "surf/" + Version + " (https://github.com/fupengl/surf)"
defaultAcceptEncoding = "gzip, deflate, br"
defaultAccept = "application/json, text/plain, */*"
defaultJsonContentType = "application/json; charset=UTF-8"
defaultTextContentType = "text/plain; charset=UTF-8"
defaultStreamContentType = "application/octet-stream"
defaultFormContentType = "application/x-www-form-urlencoded; charset=UTF-8"
)
var (
headerUserAgent = http.CanonicalHeaderKey("User-Agent")
headerAcceptEncoding = http.CanonicalHeaderKey("Accept-Encoding")
headerAccept = http.CanonicalHeaderKey("Accept")
headerLocation = http.CanonicalHeaderKey("Location")
headerContentEncoding = http.CanonicalHeaderKey("Content-Encoding")
headerContentType = http.CanonicalHeaderKey("Content-Type")
headerContentLength = http.CanonicalHeaderKey("Content-Length")
)
var (
regJsonHeader = regexp.MustCompile(`(?i:(application|text)/(.*json.*)(;|$))`)
regXmlHeader = regexp.MustCompile(`(?i:(application|text)/(.*xml.*)(;|$))`)
)