@@ -131,6 +131,8 @@ func (p *Server) Stop() error {
131
131
132
132
// handleHTTP handles regular HTTP requests and CONNECT tunneling
133
133
func (p * Server ) handleHTTP (w http.ResponseWriter , r * http.Request ) {
134
+ p .logger .Debug ("handleHTTP called" , "method" , r .Method , "url" , r .URL .String (), "host" , r .Host )
135
+
134
136
// Handle CONNECT method for HTTPS tunneling
135
137
if r .Method == "CONNECT" {
136
138
p .handleConnect (w , r )
@@ -529,21 +531,29 @@ func (p *Server) handleTLSTermination(conn net.Conn, firstByte []byte) {
529
531
530
532
// handleHTTPConnection handles regular HTTP connections
531
533
func (p * Server ) handleHTTPConnection (conn net.Conn , firstByte []byte ) {
534
+ p .logger .Debug ("Starting HTTP connection handling" )
535
+
532
536
// Create a connection that prepends the first byte we already read
533
537
connWithFirstByte := & connectionWithPrefix {
534
538
Conn : conn ,
535
539
prefix : firstByte ,
536
540
}
537
541
542
+ p .logger .Debug ("Created connection wrapper, starting HTTP server" )
543
+
538
544
// Create HTTP server to handle this connection
539
545
server := & http.Server {
540
546
Handler : http .HandlerFunc (p .handleHTTP ),
541
547
}
542
548
549
+ p .logger .Debug ("About to serve HTTP connection" )
550
+
543
551
// Serve the HTTP request
544
552
err := server .Serve (& singleConnListener {conn : connWithFirstByte })
545
553
if err != nil && err != io .EOF && ! isConnectionClosed (err ) {
546
554
p .logger .Debug ("HTTP connection error" , "error" , err )
555
+ } else {
556
+ p .logger .Debug ("HTTP connection completed successfully" )
547
557
}
548
558
}
549
559
0 commit comments