-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathhttp2settings-test.go
126 lines (124 loc) · 3.17 KB
/
http2settings-test.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package main
import (
"fmt"
http "github.com/wangluozhe/chttp"
"github.com/wangluozhe/requests"
"github.com/wangluozhe/requests/transport"
"github.com/wangluozhe/requests/url"
)
func main() {
req := url.NewRequest()
headers := &http.Header{
"User-Agent": []string{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0"},
"accept": []string{"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"},
"accept-language": []string{"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"},
"accept-encoding": []string{"gzip, deflate, br"},
"upgrade-insecure-requests": []string{"1"},
"sec-fetch-dest": []string{"document"},
"sec-fetch-mode": []string{"navigate"},
"sec-fetch-site": []string{"none"},
"sec-fetch-user": []string{"?1"},
"te": []string{"trailers"},
http.PHeaderOrderKey: []string{
":method",
":path",
":authority",
":scheme",
},
http.HeaderOrderKey: []string{
"user-agent",
"accept",
"accept-language",
"accept-encoding",
"upgrade-insecure-requests",
"sec-fetch-dest",
"sec-fetch-mode",
"sec-fetch-site",
"sec-fetch-user",
"te",
},
}
req.Headers = headers
req.Ja3 = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0"
h2s := &transport.H2Settings{
Settings: map[string]int{
"HEADER_TABLE_SIZE": 65536,
//"ENABLE_PUSH": 0,
//"MAX_HEADER_LIST_SIZE": 262144,
//"MAX_CONCURRENT_STREAMS": 1000,
"INITIAL_WINDOW_SIZE": 131072,
"MAX_FRAME_SIZE": 16384,
},
SettingsOrder: []string{
"HEADER_TABLE_SIZE",
"INITIAL_WINDOW_SIZE",
"MAX_FRAME_SIZE",
},
ConnectionFlow: 12517377,
HeaderPriority: map[string]interface{}{
"weight": 42,
"streamDep": 13,
"exclusive": false,
},
PriorityFrames: []map[string]interface{}{
{
"streamID": 3,
"priorityParam": map[string]interface{}{
"weight": 201,
"streamDep": 0,
"exclusive": false,
},
},
{
"streamID": 5,
"priorityParam": map[string]interface{}{
"weight": 101,
"streamDep": 0,
"exclusive": false,
},
},
{
"streamID": 7,
"priorityParam": map[string]interface{}{
"weight": 1,
"streamDep": 0,
"exclusive": false,
},
},
{
"streamID": 9,
"priorityParam": map[string]interface{}{
"weight": 1,
"streamDep": 7,
"exclusive": false,
},
},
{
"streamID": 11,
"priorityParam": map[string]interface{}{
"weight": 1,
"streamDep": 3,
"exclusive": false,
},
},
{
"streamID": 13,
"priorityParam": map[string]interface{}{
"weight": 241,
"streamDep": 0,
"exclusive": false,
},
},
},
}
h2ss := transport.ToHTTP2Settings(h2s)
req.HTTP2Settings = h2ss
r, err := requests.Get("https://tls.peet.ws/api/all", req)
if err != nil {
fmt.Println(err)
}
fmt.Println(r.Request.Headers)
fmt.Println("url:", r.Url)
fmt.Println("headers:", r.Headers)
fmt.Println("text:", r.Text)
}