github.com/gospider007/requests@v0.0.0-20240506025355-c73d46169a23/test/request/stream_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/gospider007/requests" 7 ) 8 9 func TestStream(t *testing.T) { 10 resp, err := requests.Get(nil, "https://httpbin.org/anything", requests.RequestOption{ 11 Stream: true, 12 }) 13 if err != nil { 14 t.Fatal(err) 15 } 16 if resp.IsStream() { 17 if resp.StatusCode() != 200 { 18 t.Fatal("resp.StatusCode()!= 200") 19 } 20 resp.CloseBody() 21 resp.CloseBody() 22 } else { 23 t.Fatal("resp.IsStream() is false") 24 } 25 }