feat(torrents): add HTTP-boundary Torrent probe harness and test script

This commit is contained in:
NimBold
2026-08-01 18:50:25 +03:30
parent 18b51ca86e
commit a00d34edc8
4 changed files with 784 additions and 1 deletions
+24 -1
View File
@@ -3267,7 +3267,30 @@ pub(crate) async fn rpc_call(
.await
.map_err(|e| e.to_string())?;
let json: serde_json::Value = res.json().await.map_err(|e| e.to_string())?;
let http_status = res.status();
let body = res.text().await.map_err(|e| e.to_string())?;
let json: serde_json::Value = serde_json::from_str(&body).map_err(|error| {
if http_status.is_success() {
error.to_string()
} else {
format!(
"HTTP {} {}: invalid JSON-RPC response: {error}",
http_status.as_u16(),
http_status.canonical_reason().unwrap_or("response error")
)
}
})?;
if !http_status.is_success() {
let detail = json
.get("error")
.map(serde_json::Value::to_string)
.unwrap_or_else(|| "aria2 returned no JSON-RPC error".to_string());
return Err(format!(
"HTTP {} {}: {detail}",
http_status.as_u16(),
http_status.canonical_reason().unwrap_or("response error")
));
}
if let Some(error) = json.get("error") {
return Err(error.to_string());
}