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

     1  package main
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/gospider007/gtls"
     7  	"github.com/gospider007/requests"
     8  )
     9  
    10  func TestAddType(t *testing.T) {
    11  	session, _ := requests.NewClient(nil, requests.ClientOption{
    12  		AddrType: gtls.Ipv4, // Prioritize parsing IPv4 addresses
    13  	})
    14  	resp, err := session.Get(nil, "https://test.ipw.cn")
    15  	if err != nil {
    16  		t.Error(err)
    17  	}
    18  	if resp.StatusCode() != 200 {
    19  		t.Errorf("status code error, expected 200, got %d", resp.StatusCode())
    20  	}
    21  }