mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
sync
This commit is contained in:
@@ -4,7 +4,10 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gospider007/gtls"
|
||||
"github.com/gospider007/proxy"
|
||||
"github.com/gospider007/requests"
|
||||
)
|
||||
|
||||
@@ -27,6 +30,44 @@ func TestHttp3(t *testing.T) {
|
||||
t.Error("resp.Proto!= HTTP/3.0")
|
||||
}
|
||||
}
|
||||
func TestHttp3Proxy(t *testing.T) {
|
||||
proxyAddress := "127.0.0.1:1080"
|
||||
// server, err := socks5.NewClassicServer("127.0.0.1:1080", "127.0.0.1", "", "", 0, 0)
|
||||
// if err != nil {
|
||||
// log.Println(err)
|
||||
// return
|
||||
// }
|
||||
// go server.ListenAndServe(nil)
|
||||
proxyC, err := proxy.NewClient(nil, proxy.ClientOption{Addr: proxyAddress, DisVerify: true})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
defer proxyC.Close()
|
||||
go proxyC.Run()
|
||||
|
||||
// [0 87 164 1 116 253 33 138 106 82]
|
||||
// [0 87 162 31 139 8 0 0 0 0]
|
||||
time.Sleep(time.Second)
|
||||
// href := "https://google.com"
|
||||
href := "https://cloudflare-quic.com/"
|
||||
|
||||
resp, err := requests.Get(context.Background(), href,
|
||||
requests.RequestOption{
|
||||
ClientOption: requests.ClientOption{
|
||||
DialOption: requests.DialOption{
|
||||
// AddrType: gtls.Ipv4,
|
||||
GetAddrType: func(host string) gtls.AddrType {
|
||||
log.Print("我开始喽")
|
||||
return gtls.Ipv4
|
||||
},
|
||||
},
|
||||
Proxy: "socks5://" + proxyAddress,
|
||||
ForceHttp3: true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
return
|
||||
}
|
||||
log.Print(resp.StatusCode())
|
||||
log.Print(resp.Proto())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user