chore: clean up MITM logs and add Google SSE tests

- Demote non-LLM request logs to debug (only streamGenerateContent at info)
- Demote non-streaming response headers to debug
- Add 5 Google SSE parser tests (single event, multi-event accumulation,
  chunked framing, completion detection, no-thinking-tokens)
- Fix unused variable warning in proxy.rs
This commit is contained in:
Nikketryhard
2026-02-14 17:55:17 -06:00
parent d4de436856
commit ca36ab0631
2 changed files with 177 additions and 13 deletions

View File

@@ -512,7 +512,7 @@ async fn handle_http_over_tls(
}
// Parse the HTTP request to find headers and body
let (headers_end, content_length, is_streaming_request) = parse_http_request_meta(&request_buf);
let (headers_end, content_length, _is_streaming_request) = parse_http_request_meta(&request_buf);
// Try to extract cascade hint from request body
let cascade_hint = if headers_end < request_buf.len() {
@@ -533,14 +533,22 @@ async fn handle_http_over_tls(
}
};
info!(
domain,
req_path = %req_path,
content_length,
streaming = is_streaming_request,
cascade = ?cascade_hint,
"MITM: forwarding request"
);
// Log LLM calls at info, everything else at debug
if req_path.contains("streamGenerateContent") {
info!(
domain,
req_path = %req_path,
cascade = ?cascade_hint,
"MITM: forwarding LLM request"
);
} else {
debug!(
domain,
req_path = %req_path,
content_length,
"MITM: forwarding request"
);
}
// ── Ensure upstream connection is alive ──────────────────────────────
// Lazily connect on first request, or reconnect if the previous connection died
@@ -643,10 +651,15 @@ async fn handle_http_over_tls(
}
}
info!(domain, streaming = is_streaming_response,
content_length = ?response_content_length,
content_type = %content_type,
status = resp.code, "MITM: got response headers");
if is_streaming_response {
info!(domain,
content_type = %content_type,
status = resp.code, "MITM: streaming response");
} else {
debug!(domain,
content_type = %content_type,
status = resp.code, "MITM: response headers");
}
headers_parsed = true;
// Save body for usage parsing