mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
sync
This commit is contained in:
14
socks5.go
14
socks5.go
@@ -48,17 +48,23 @@ func WriteUdpAddr(w io.Writer, addr Address) error {
|
||||
return err
|
||||
}
|
||||
} else if addr.Name != "" {
|
||||
if len(addr.Name) > 255 {
|
||||
l := len(addr.Name)
|
||||
if l > 255 {
|
||||
return errors.New("errStringTooLong")
|
||||
}
|
||||
con := make([]byte, 2+len(addr.Name))
|
||||
con := make([]byte, 2+l+2)
|
||||
con[0] = fqdnAddress
|
||||
con[1] = byte(len(addr.Name))
|
||||
con[1] = byte(l)
|
||||
copy(con[2:], []byte(addr.Name))
|
||||
binary.BigEndian.PutUint16(con[2+l:], uint16(addr.Port))
|
||||
_, err := w.Write(con)
|
||||
return err
|
||||
} else {
|
||||
_, err := w.Write([]byte{ipv4Address, 0, 0, 0, 0})
|
||||
con := make([]byte, 1+4+2)
|
||||
con[0] = ipv4Address
|
||||
copy(con[1:], net.IPv4(0, 0, 0, 0))
|
||||
binary.BigEndian.PutUint16(con[1+4:], uint16(addr.Port))
|
||||
_, err := w.Write(con)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ func TestHttp2(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
if resp.StatusCode() != 200 {
|
||||
t.Error("resp.StatusCode!= 200")
|
||||
t.Error("resp.StatusCode2!= 200")
|
||||
}
|
||||
if resp.Proto() != "HTTP/2.0" {
|
||||
t.Error("resp.Proto!= HTTP/2.0")
|
||||
@@ -28,4 +28,14 @@ func TestHttp2(t *testing.T) {
|
||||
if resp.Proto() != "HTTP/2.0" {
|
||||
t.Error("resp.Proto!= HTTP/2.0")
|
||||
}
|
||||
resp, err = requests.Post(context.TODO(), "https://mp.weixin.qq.com", requests.RequestOption{Body: "fasfasfsdfdssdsfasdfasdfsadfsdf对方是大翻身大翻身大翻身对方的身份"})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if resp.StatusCode() != 200 {
|
||||
t.Error("resp.StatusCode!= 200")
|
||||
}
|
||||
if resp.Proto() != "HTTP/2.0" {
|
||||
t.Error("resp.Proto!= HTTP/2.0")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user