Commit f6a1522
Fix nil req.URL crash for gRPC/HTTP2 requests in MITM mode
When gRPC clients (like dolt's eventsapi) connect through the MITM proxy,
they use HTTP/2 which doesn't have a traditional request-line. Instead,
HTTP/2 uses pseudo-headers (:method, :path, :authority, :scheme).
goproxy was designed for HTTP/1.1 and doesn't properly reconstruct req.URL
from HTTP/2 pseudo-headers in MITM mode, leaving it nil. This caused the
proxy to crash when accessing req.URL.Host.
This fix:
- Detects when req.URL is nil
- Logs diagnostic information (Method, Host, RequestURI, Proto)
- Reconstructs req.URL from req.Host and req.RequestURI when available
- Only returns an error if reconstruction is impossible
This allows gRPC traffic (eventsapi.dolthub.com) to flow through the proxy
while still catching genuinely malformed requests.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent a2eef3c commit f6a1522
1 file changed
Lines changed: 23 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
396 | 397 | | |
397 | 398 | | |
398 | 399 | | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
405 | 422 | | |
406 | 423 | | |
407 | 424 | | |
| |||
0 commit comments