mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
add localAddr test
This commit is contained in:
@@ -25,6 +25,7 @@ Requests is a fully featured HTTP client library for Golang. Network requests ca
|
||||
* [Form request](https://github.com/gospider007/requests/blob/master/test/request/form_test.go) with `multipart/form-data`
|
||||
* [Flow request](https://github.com/gospider007/requests/blob/master/test/request/stream_test.go)
|
||||
* [Request URL Path Params](https://github.com/gospider007/requests/blob/master/test/request/params_test.go)
|
||||
* [Local network card](https://github.com/gospider007/requests/blob/master/test/request/params_test.go)
|
||||
* [Response](https://github.com/gospider007/requests/tree/master/test/response)
|
||||
* [Return whether to reuse connections](https://github.com/gospider007/requests/blob/master/test/response/isNewConn_test.go)
|
||||
* [Middleware](https://github.com/gospider007/requests/tree/master/test/middleware)
|
||||
|
||||
22
test/localAddr_test.go
Normal file
22
test/localAddr_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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{
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user