Add headers
This commit is contained in:
parent
5b5352710e
commit
5193153e09
1 changed files with 26 additions and 8 deletions
|
|
@ -202,13 +202,16 @@ impl HttpApi {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let content = match added {
|
let (info, content) = match added {
|
||||||
crate::AddTorrentResponse::AlreadyManaged(_, handle) => {
|
crate::AddTorrentResponse::AlreadyManaged(_, handle) => (
|
||||||
handle.info().torrent_bytes.clone().0
|
handle.info().info.clone(),
|
||||||
}
|
handle.info().torrent_bytes.clone().0,
|
||||||
crate::AddTorrentResponse::ListOnly(ListOnlyResponse { torrent_bytes, .. }) => {
|
),
|
||||||
torrent_bytes.0
|
crate::AddTorrentResponse::ListOnly(ListOnlyResponse {
|
||||||
}
|
info,
|
||||||
|
torrent_bytes,
|
||||||
|
..
|
||||||
|
}) => (info, torrent_bytes.0),
|
||||||
crate::AddTorrentResponse::Added(_, _) => {
|
crate::AddTorrentResponse::Added(_, _) => {
|
||||||
return Err(ApiError::new_from_text(
|
return Err(ApiError::new_from_text(
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
|
@ -216,7 +219,22 @@ impl HttpApi {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(content)
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert(
|
||||||
|
"Content-Type",
|
||||||
|
HeaderValue::from_static("application/x-bittorrent"),
|
||||||
|
);
|
||||||
|
|
||||||
|
if let Some(name) = info.name.as_ref() {
|
||||||
|
if let Ok(name) = std::str::from_utf8(&name) {
|
||||||
|
if let Ok(h) =
|
||||||
|
HeaderValue::from_str(&format!("attachment; filename=\"{}.torrent\"", name))
|
||||||
|
{
|
||||||
|
headers.insert("Content-Disposition", h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok((headers, content))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn torrent_playlist(
|
async fn torrent_playlist(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue