mirror of
https://github.com/fumiama/terasu.git
synced 2026-06-10 21:24:46 +08:00
fix: error on different frag lens
This commit is contained in:
44
conn_test.go
44
conn_test.go
@@ -9,6 +9,50 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHTTPDialDifferentFragLen(t *testing.T) {
|
||||
cli := http.Client{
|
||||
Transport: &http.Transport{
|
||||
DialTLS: func(network, addr string) (net.Conn, error) {
|
||||
conn, err := net.DialTCP("tcp", nil, net.TCPAddrFromAddrPort(
|
||||
netip.MustParseAddrPort("52.222.136.117:443"),
|
||||
))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t.Log("net.Dial succeeded")
|
||||
tlsConn := tls.Client(NewConn(conn), &tls.Config{
|
||||
ServerName: "huggingface.co",
|
||||
MinVersion: tls.VersionTLS12,
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
err = tlsConn.Handshake()
|
||||
if err != nil {
|
||||
_ = tlsConn.Close()
|
||||
return nil, err
|
||||
}
|
||||
return tlsConn, nil
|
||||
},
|
||||
},
|
||||
}
|
||||
for i := 0; i < 10; i++ {
|
||||
// will fail when i=0 in CN
|
||||
DefaultFirstFragmentLen = i
|
||||
resp, err := cli.Get("https://huggingface.co/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatal("status code:", resp.StatusCode)
|
||||
}
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(string(data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPDialTLS13(t *testing.T) {
|
||||
cli := http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
||||
Reference in New Issue
Block a user