-
Notifications
You must be signed in to change notification settings - Fork 1
/
var.go
68 lines (55 loc) · 2.32 KB
/
var.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
67
68
package viot
import (
"errors"
"time"
"github.com/456vv/vweb/v2"
)
// 默认读取数据行大小
const DefaultLineBytes = 1 << 20 // 1 MB
// maxInt32是服务器和传输的字节限制读取器的有效“无限”值。
const maxInt32 int = 1<<31 - 1
var (
ErrBodyNotAllowed = errors.New("viot: The request method or status code is not allowed")
ErrGetBodyed = errors.New("viot: Does not support repeated reading of body")
ErrHijacked = errors.New("viot: Connection has been hijacked")
ErrLaunched = errors.New("viot: The connection is waiting for the response of the active request")
ErrRwaControl = errors.New("viot: Processing the original data")
ErrAbortHandler = errors.New("viot: Abort processing")
ErrServerClosed = errors.New("viot: Server is down")
ErrDoned = errors.New("viot: Has been completed")
ErrConnClose = errors.New("viot: Device connection is closed")
ErrReqUnavailable = errors.New("viot: Request unavailable")
ErrRespUnavailable = errors.New("viot: Response unavailable")
ErrRespNonce = errors.New("viot: Response nonce not recognized")
ErrHostInvalid = errors.New("host invalid")
ErrURIInvalid = errors.New("URI invalid")
ErrProtoInvalid = errors.New("proto Invalid")
ErrMethodInvalid = errors.New("method Invalid")
)
// 检测服务器下线时间间隔
var shutdownPollInterval = 500 * time.Millisecond
// aLongTimeAgo是一个非零时间,远在过去,用于立即取消网络操作。
var aLongTimeAgo = time.Unix(1, 0)
// 方法集
var methods = []string{"GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS"}
// 请求特征
var reqFeature1 = []string{"\"nonce\"", "\"proto\"", "\"method\"", "\"path\"", "\"home\""} // 过时的,暂时保留
var reqFeature2 = []string{"\"nonce\"", "\"proto\"", "\"method\"", "\"path\"", "\"host\""}
// 响应特征
var respFeature1 = []string{"\"nonce\"", "\"status\""}
type (
Session = vweb.Session
Sessions = vweb.Sessions
Globaler = vweb.Globaler
Sessioner = vweb.Sessioner
SiteMan = vweb.SiteMan
Site = vweb.Site
)
// 上下文中使用的key
var (
LocalAddrContextKey = &contextKey{"iot-localAddr"}
ListenerContextKey = &contextKey{"iot-listener"}
ConnContextKey = &contextKey{"iot-conn"}
ServerContextKey = &contextKey{"iot-server"}
SiteContextKey = &contextKey{"iot-site"}
)