AstrBot-Desktop/src-tauri/src/networking
YokiiroBW 0b4a7de62a
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
fix(astrbot): resolve an attachment's type from its bytes when needed
An attachment downloaded and then rendered as a broken image. A blob URL
is decoded according to the blob's type, so handing the webview
application/octet-stream makes img refuse bytes that are a perfectly
good PNG — and octet-stream is exactly what the client substitutes when
the server names no type.

Prefer a concrete image type from the server, otherwise identify the
format from its leading bytes. Every signature checked is a fixed marker
at a fixed offset, so this reads no user content, and a JSON error body
served with HTTP 200 is deliberately not mistaken for an image.

Whether that was the cause is not yet established, so the alternative is
made self-diagnosing rather than guessed at. The download outcome —
status, the type the server gave, the type the bytes indicate, and the
length — is now traced, and the frontend reports why an attachment did
not render instead of leaving a bare broken-image icon: a failed
download shows its error, and a payload the browser cannot decode says
so. Both paths were previously swallowed.

Refs: N-6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:29:33 +08:00
..
astrbot_client.rs fix(astrbot): resolve an attachment's type from its bytes when needed 2026-07-27 02:29:33 +08:00
commands.rs fix(chat): validate slot sends before writing history 2026-07-27 00:20:09 +08:00
gateway_client.rs fix(astrbot): scope stream event ids and fix the transport layer 2026-07-26 23:12:56 +08:00
manager.rs feat(p00): add Tauri desktop spike foundation 2026-07-18 20:34:47 +08:00
mod.rs fix(chat): validate slot sends before writing history 2026-07-27 00:20:09 +08:00
runtime.rs fix(chat): validate slot sends before writing history 2026-07-27 00:20:09 +08:00