/
types.go
74 lines (64 loc) · 1.56 KB
/
types.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
69
70
71
72
73
74
package cclient_v2
import (
"context"
"io"
"net/http"
"net/textproto"
"net/url"
tlsUtls "github.com/refraction-networking/utls"
tlsHttp "github.com/useflyent/fhttp"
"github.com/useflyent/fhttp/http2"
)
type Client struct {
Context context.Context
proxy string
useTLS bool
MasterHeaderOrder []string
http2Headers map[http2.SettingID]uint32
tlsClient *tlsHttp.Client
clientHello tlsUtls.ClientHelloID
httpClient *http.Client
}
// Request base request struct
type Request struct {
useTLS bool
Context context.Context
HeaderOrder []string
TLSRequest TLSRequest
HTTPRequest HTTPRequest
}
// TLSRequest tls request struct
type TLSRequest struct {
client *Client
method, url, host string
header tlsHttp.Header
body io.Reader
cookies []*tlsHttp.Cookie
}
// HTTPRequest non-tls request struct
type HTTPRequest struct {
client *Client
method, url, host string
header http.Header
body io.Reader
cookies []*http.Cookie
}
// Response base response struct
type Response struct {
request *http.Request
requestCookies []*http.Cookie
cookies []*http.Cookie
IsTLS bool
headers Header
body []byte
reqUrl *url.URL
status string
statusCode int
}
type Header map[string][]string
func (h Header) Get(key string) string {
return textproto.MIMEHeader(h).Get(key)
}
func (h Header) Values(key string) []string {
return textproto.MIMEHeader(h).Values(key)
}