From 3febe79b153945e2834684e9df18e5e95f344b2d Mon Sep 17 00:00:00 2001 From: ospab Date: Thu, 21 May 2026 14:35:45 +0300 Subject: [PATCH] feat: log raw HTTP response on UoT handshake failure --- ostp-client/src/transport/xhttp.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ostp-client/src/transport/xhttp.rs b/ostp-client/src/transport/xhttp.rs index 2fd7cce..1b8ed69 100644 --- a/ostp-client/src/transport/xhttp.rs +++ b/ostp-client/src/transport/xhttp.rs @@ -131,7 +131,8 @@ pub async fn connect_xhttp( anyhow::bail!("xHTTP handshake failed: expected 101 or 200, got: {}", resp.lines().next().unwrap_or("")); } if !resp.to_ascii_lowercase().contains("x-ostp-server:") { - anyhow::bail!("xHTTP handshake failed: endpoint is not an OSTP server (missing X-Ostp-Server header)"); + let safe_resp = resp.chars().take(200).collect::().replace("\r\n", " | "); + anyhow::bail!("xHTTP handshake failed: endpoint is not an OSTP server. Got: {}", safe_resp); } // Extract leftover payload if any @@ -159,7 +160,8 @@ pub async fn connect_xhttp( anyhow::bail!("xHTTP handshake failed: expected 101 or 200, got: {}", resp.lines().next().unwrap_or("")); } if !resp.to_ascii_lowercase().contains("x-ostp-server:") { - anyhow::bail!("xHTTP handshake failed: endpoint is not an OSTP server (missing X-Ostp-Server header)"); + let safe_resp = resp.chars().take(200).collect::().replace("\r\n", " | "); + anyhow::bail!("xHTTP handshake failed: endpoint is not an OSTP server. Got: {}", safe_resp); } let headers_end = buf[..header_len].windows(4).position(|w| w == b"\r\n\r\n").unwrap() + 4;