github.com/gospider007/requests@v0.0.0-20240506025355-c73d46169a23/test/fingerprint/http2_test.go (about) 1 package main 2 3 import ( 4 "log" 5 "testing" 6 7 "github.com/gospider007/ja3" 8 "github.com/gospider007/requests" 9 ) 10 11 func TestH2(t *testing.T) { 12 j := "1:65536,2:0,4:6291456,6:262144|15663105|0|m,a,s,p" 13 j2 := "1:65536;2:0;4:6291456;6:262144|15663105|0|m,a,s,p" 14 h2Spec, err := ja3.CreateH2SpecWithStr(j) //create h2 spec with string 15 if err != nil { 16 t.Fatal(err) 17 } 18 // log.Print(h2Spec) 19 resp, err := requests.Get(nil, "https://tools.scrapfly.io/api/fp/anything", requests.RequestOption{ 20 H2Ja3Spec: h2Spec, //set h2 spec 21 }) 22 // log.Print(resp.Text()) 23 if err != nil { 24 t.Fatal(err) 25 } 26 27 jsonData, err := resp.Json() 28 ja3 := jsonData.Get("http2.fingerprint") 29 if !ja3.Exists() { 30 t.Fatal("not found http2") 31 } 32 if j2 != ja3.String() { 33 log.Print(j) 34 log.Print(ja3) 35 t.Fatal("not equal") 36 } 37 }