@@ -656,6 +656,53 @@ func TestRunWithHTTP3(t *testing.T) {
656656 assert .Contains (t , data , "HTTP/3 test response" , "Response should contain HTTP/3 test data" )
657657}
658658
659+ // TestRunWithHTTP3AndConnectTo tests the --http3 flag combined with --connect-to.
660+ func TestRunWithHTTP3AndConnectTo (t * testing.T ) {
661+ // Create an HTTP/3 test server (our actual target)
662+ h3Server , serverAddr := createTestHTTP3Server (t )
663+ defer func () {
664+ _ = h3Server .Close ()
665+ }()
666+
667+ // Create buffers for output
668+ dataBuffer := & bytes.Buffer {}
669+ logBuffer := & bytes.Buffer {}
670+
671+ // Create a fake hostname that will be redirected to the real server
672+ fakeHost := "fake-http3.example.com:443"
673+
674+ // Parse config with --http3 and --connect-to arguments
675+ // Format: HOST1:PORT1:HOST2:PORT2
676+ // We redirect fake-http3.example.com:443 to the actual test server
677+ connectToValue := fmt .Sprintf ("fake-http3.example.com:443:%s" , serverAddr )
678+ args := []string {
679+ "--http3" ,
680+ "--insecure" ,
681+ "--connect-to" , connectToValue ,
682+ "https://fake-http3.example.com:443/get" ,
683+ }
684+ cfg , err := config .ParseConfig (args )
685+ require .NoError (t , err )
686+
687+ // Verify the connect-to mapping was parsed correctly
688+ require .NotNil (t , cfg .ConnectTo )
689+ require .Equal (t , serverAddr , cfg .ConnectTo [fakeHost ])
690+
691+ // Verify that ForceHTTP3 is set to true
692+ assert .True (t , cfg .ForceHTTP3 , "ForceHTTP3 should be set to true when --http3 flag is used" )
693+
694+ // Create output with mock writers
695+ out := output .NewOutputWithWriters (dataBuffer , logBuffer , cfg .Verbose , cfg .OutputJSON )
696+
697+ // Run the command
698+ err = cmd .Run (cfg , out )
699+ require .NoError (t , err )
700+
701+ // If the request succeeded (connect-to worked), verify the output
702+ data := dataBuffer .String ()
703+ assert .Contains (t , data , "HTTP/3 test response" , "Response should contain HTTP/3 test data" )
704+ }
705+
659706// createTestProxy creates a test HTTP CONNECT proxy server that tracks requests.
660707// Returns the proxy server and a pointer to a boolean that indicates if the proxy
661708// received a request.
0 commit comments