Files
requests/test/request/localAddr_test.go
gospider 9562a203fa sync
2025-01-14 09:13:38 +08:00

27 lines
523 B
Go

package main
import (
"net"
"testing"
"github.com/gospider007/requests"
)
func TestLocalAddr(t *testing.T) {
resp, err := requests.Get(nil, "https://httpbin.org/anything", requests.RequestOption{
ClientOption: requests.ClientOption{
DialOption: requests.DialOption{
LocalAddr: &net.TCPAddr{ //set dns server
IP: net.ParseIP("192.168.1.239"),
},
},
},
})
if err != nil {
t.Fatal(err)
}
if resp.StatusCode() != 200 {
t.Fatal("http status code is not 200")
}
}