github.com/gospider007/requests@v0.0.0-20240506025355-c73d46169a23/test/dns_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net"
     5  	"testing"
     6  
     7  	"github.com/gospider007/requests"
     8  )
     9  
    10  func TestDns(t *testing.T) {
    11  	resp, err := requests.Get(nil, "https://httpbin.org/anything", requests.RequestOption{
    12  		Dns: &net.UDPAddr{ //set dns server
    13  			IP:   net.ParseIP("223.5.5.5"),
    14  			Port: 53,
    15  		},
    16  	})
    17  	if err != nil {
    18  		t.Fatal(err)
    19  	}
    20  	if resp.StatusCode() != 200 {
    21  		t.Fatal("http status code is not 200")
    22  	}
    23  }