-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathresponse_sample.tengo
35 lines (35 loc) · 1.33 KB
/
response_sample.tengo
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
// A sample for modifing response, try https://httpbin.org/get
// [CA]
modules = append(modules, {
address: func(m) {
if m.network == "tcp" && m.domainaddress {
if m.domainaddress == "httpbin.org:443" {
return { mitm: true, mitmprotocol: "https", mitmwithbody: true, mitmautohandlecompress: true}
}
if m.domainaddress == "httpbin.org:80" {
return { mitm: true, mitmprotocol: "http", mitmwithbody: true, mitmautohandlecompress: true }
}
return
}
if m.network == "udp" && m.domainaddress {
if m.domainaddress == "httpbin.org:443" {
return { block: true }
}
}
},
httpresponse: func(request, response) {
if request["URL"] == "http://httpbin.org/get" || request["URL"] == "https://httpbin.org/get" {
delete(response, "Alt-Svc") // Avoid upgrading to http3 from http1 or http2
delete(response, "Content-Security-Policy")
json := import("json")
j := json.decode(response["Body"])
if is_error(j) {
return j
}
j.brook = "一曲肝长断!"
j.shiliew = "天涯何处觅知音!"
response["Body"] = json.encode(j)
return response
}
}
})