diff --git a/crates/librqbit/src/http_api.rs b/crates/librqbit/src/http_api.rs index a90a7986a..d29625434 100644 --- a/crates/librqbit/src/http_api.rs +++ b/crates/librqbit/src/http_api.rs @@ -7,7 +7,7 @@ use bencode::AsDisplay; use buffers::ByteBuf; use futures::future::BoxFuture; use futures::{FutureExt, TryStreamExt}; -use http::{HeaderMap, HeaderValue, StatusCode}; +use http::{HeaderMap, HeaderName, HeaderValue, StatusCode}; use itertools::Itertools; use serde::{Deserialize, Serialize}; @@ -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"; - output_headers.insert( - "contentFeatures.dlna.org", - HeaderValue::from_static("DLNA.ORG_OP=01"), - ); + 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")); + } + + 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(