Skip to content

Commit

Permalink
Conditionally insert DLNA headers only if asked for
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatson committed Sep 2, 2024
1 parent f96a902 commit 86c6805
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions crates/librqbit/src/http_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,28 @@ impl HttpApi {
let mut output_headers = HeaderMap::new();
output_headers.insert("Accept-Ranges", HeaderValue::from_static("bytes"));

output_headers.insert(
"transferMode.dlna.org",
HeaderValue::from_static("Streaming"),
);
const DLNA_TRANSFER_MODE: &str = "transferMode.dlna.org";
const DLNA_GET_CONTENT_FEATURES: &str = "getcontentFeatures.dlna.org";
const DLNA_CONTENT_FEATURES: &str = "contentFeatures.dlna.org";

if headers
.get(DLNA_TRANSFER_MODE)
.map(|v| matches!(v.as_bytes(), b"Streaming" | b"streaming"))
.unwrap_or(false)
{
output_headers.insert(DLNA_TRANSFER_MODE, HeaderValue::from_static("Streaming"));
}

output_headers.insert(
"contentFeatures.dlna.org",
HeaderValue::from_static("DLNA.ORG_OP=01"),
);
if headers
.get(DLNA_GET_CONTENT_FEATURES)
.map(|v| v.as_bytes() == b"1")
.unwrap_or(false)
{
output_headers.insert(
DLNA_CONTENT_FEATURES,
HeaderValue::from_static("DLNA.ORG_OP=01"),
);
}

if let Ok(mime) = state.torrent_file_mime_type(idx, file_id) {
output_headers.insert(
Expand Down

0 comments on commit 86c6805

Please sign in to comment.