File tree 1 file changed +21
-0
lines changed 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import (
32
32
"sync/atomic"
33
33
"testing"
34
34
"time"
35
+ "unsafe"
35
36
36
37
"golang.org/x/net/http2/hpack"
37
38
)
@@ -594,6 +595,26 @@ func TestTransportDialTLS(t *testing.T) {
594
595
}
595
596
}
596
597
598
+ func TestConfigureTransportWithOptions (t * testing.T ) {
599
+ t1 := & http.Transport {}
600
+ err := ConfigureTransport (t1 , WithReadIdleTimeout (10 * time .Second ), WithPingTimeout (2 * time .Second ))
601
+ if err != nil {
602
+ t .Fatal (err )
603
+ }
604
+ rf := reflect .ValueOf (t1 ).Elem ().FieldByName ("altProto" )
605
+ rf = reflect .NewAt (rf .Type (), unsafe .Pointer (rf .UnsafeAddr ())).Elem ()
606
+ v := rf .Interface ().(atomic.Value )
607
+ altProto := v .Load ().(map [string ]http.RoundTripper )
608
+ rt := (altProto ["https" ]).(noDialH2RoundTripper )
609
+ t2 := rt .Transport
610
+ if t2 .ReadIdleTimeout != 10 * time .Second {
611
+ t .Errorf ("expected ReadIdleTimeout to be 10s, got %v" , t2 .ReadIdleTimeout )
612
+ }
613
+ if t2 .PingTimeout != 2 * time .Second {
614
+ t .Errorf ("expected PingTimeout to be 2s, got %v" , t2 .PingTimeout )
615
+ }
616
+ }
617
+
597
618
func TestConfigureTransport (t * testing.T ) {
598
619
t1 := & http.Transport {}
599
620
err := ConfigureTransport (t1 , WithReadIdleTimeout (3 * time .Second ), WithPingTimeout (1 * time .Second ))
You can’t perform that action at this time.
0 commit comments