fix(streamable-http): map stale session 401 to status-aware error (#709)

* fix(streamable-http): map stale session 401 to status-aware error

* test(streamable-http): expect 404 for stale session
This commit is contained in:
Adam Kowalski 2026-03-03 09:01:14 -08:00 • committed by GitHub
commit 1fe5d1e1cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -186,6 +186,15 @@ impl StreamableHttpClient for reqwest::Client {
) {
return Ok(StreamableHttpPostResponse::Accepted);
}
if !status.is_success() {
let body = response
.text()
.await
.unwrap_or_else(|_| "<failed to read response body>".to_owned());
return Err(StreamableHttpError::UnexpectedServerResponse(Cow::Owned(
format!("HTTP {status}: {body}"),
)));
}
let content_type = response.headers().get(reqwest::header::CONTENT_TYPE);
let session_id = response.headers().get(HEADER_SESSION_ID);
let session_id = session_id