-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastreq.go
66 lines (54 loc) · 1.96 KB
/
fastreq.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package fastreq
import "time"
// Version of fastreq
const Version = "0.3.2"
const defaultUserAgent = "fastreq@" + Version
// HTTPMethod http request method
type HTTPMethod string
const (
GET HTTPMethod = "GET" // RFC 7231, 4.3.1
HEAD HTTPMethod = "HEAD" // RFC 7231, 4.3.2
POST HTTPMethod = "POST" // RFC 7231, 4.3.3
PUT HTTPMethod = "PUT" // RFC 7231, 4.3.4
PATCH HTTPMethod = "PATCH" // RFC 5789
DELETE HTTPMethod = "DELETE" // RFC 7231, 4.3.5
CONNECT HTTPMethod = "CONNECT" // RFC 7231, 4.3.6
OPTIONS HTTPMethod = "OPTIONS" // RFC 7231, 4.3.7
)
const (
MIMETextXML = "text/xml"
MIMETextHTML = "text/html"
MIMETextPlain = "text/plain"
MIMEApplicationXML = "application/xml"
MIMEApplicationJSON = "application/json"
MIMEApplicationJavaScript = "application/javascript"
MIMEApplicationForm = "application/x-www-form-urlencoded"
MIMEOctetStream = "application/octet-stream"
MIMEMultipartForm = "multipart/form-data"
MIMETextXMLCharsetUTF8 = "text/xml; charset=utf-8"
MIMETextHTMLCharsetUTF8 = "text/html; charset=utf-8"
MIMETextPlainCharsetUTF8 = "text/plain; charset=utf-8"
MIMEApplicationXMLCharsetUTF8 = "application/xml; charset=utf-8"
MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8"
MIMEApplicationJavaScriptCharsetUTF8 = "application/javascript; charset=utf-8"
)
const defaultTimeout = time.Second * 30
// DebugLevel debug log level
type DebugLevel int
const (
DebugClose DebugLevel = iota // close debug
DebugSimple
DebugDetail
)
// debugLimit limit length of debug logging output
const debugLimit = 10000
type Releaser interface {
// Releases any resources
Release()
}
// Releases any resources
func Release(releasers ...Releaser) {
for _, r := range releasers {
r.Release()
}
}