@@ -50,34 +50,36 @@ func TestAgentRuntimeInstallE2ERetriesInterruptedWindowsDownload(t *testing.T) {
5050 t .Setenv (codexcli .EnvBinaryPath , target )
5151 binaryPayload := apiTestPEBinary ("amd64" )
5252 var downloads atomic.Int32
53- downloadServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
53+ downloadServer := httptest .NewUnstartedServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
5454 if r .URL .Path != "/windows/amd64" || r .URL .Query ().Get ("package" ) != "codex-cli" {
5555 t .Errorf ("download URL = %s, want /windows/amd64?package=codex-cli" , r .URL .String ())
5656 }
57+ if r .Proto != "HTTP/2.0" {
58+ t .Errorf ("download protocol = %s, want HTTP/2.0" , r .Proto )
59+ }
5760 if downloads .Add (1 ) == 1 {
58- hijacker , ok := w .(http.Hijacker )
61+ flusher , ok := w .(http.Flusher )
5962 if ! ok {
60- t .Fatal ("download response does not support connection hijacking" )
61- }
62- connection , buffered , err := hijacker .Hijack ()
63- if err != nil {
64- t .Errorf ("Hijack() error = %v" , err )
63+ t .Error ("download response does not support flushing" )
6564 return
6665 }
67- defer connection . Close ( )
68- _ , _ = buffered . WriteString ( "HTTP/1.1 200 OK \r \n Content-Length: " + strconv . Itoa ( len ( binaryPayload )) + " \r \n \r \n " )
69- _ , _ = buffered .Write (binaryPayload [:len (binaryPayload )/ 2 ])
70- _ = buffered .Flush ()
71- return
66+ w . Header (). Set ( "Content-Length" , strconv . Itoa ( len ( binaryPayload )) )
67+ w . WriteHeader ( http . StatusOK )
68+ _ , _ = w .Write (binaryPayload [:len (binaryPayload )/ 2 ])
69+ flusher .Flush ()
70+ panic ( http . ErrAbortHandler )
7271 }
7372 w .WriteHeader (http .StatusOK )
7473 _ , _ = w .Write (binaryPayload )
7574 }))
75+ downloadServer .EnableHTTP2 = true
76+ downloadServer .StartTLS ()
7677 defer downloadServer .Close ()
7778 installer := codexcli .NewInstaller (codexcli.InstallerOptions {
78- BaseURL : downloadServer .URL ,
79- GOOS : "windows" ,
80- GOARCH : "amd64" ,
79+ HTTPClient : downloadServer .Client (),
80+ BaseURL : downloadServer .URL ,
81+ GOOS : "windows" ,
82+ GOARCH : "amd64" ,
8183 })
8284 handler := & Handler {}
8385 handler .SetAgentRuntimeService (runtimecatalog .NewService (
0 commit comments