From 99ffeec3239ee5f69a909c91a0028c15b957a574 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Thu, 29 Aug 2024 12:06:03 +0100 Subject: [PATCH] Implement GetProtocolInfo --- .../connection_manager/control/get_protocol_info.xml | 11 +++++++++++ crates/upnp-serve/src/services/connection_manager.rs | 12 +++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 crates/upnp-serve/src/resources/templates/connection_manager/control/get_protocol_info.xml diff --git a/crates/upnp-serve/src/resources/templates/connection_manager/control/get_protocol_info.xml b/crates/upnp-serve/src/resources/templates/connection_manager/control/get_protocol_info.xml new file mode 100644 index 0000000..3845b72 --- /dev/null +++ b/crates/upnp-serve/src/resources/templates/connection_manager/control/get_protocol_info.xml @@ -0,0 +1,11 @@ + + + + + http-get:*:*:DLNA.ORG_OP=01 + + + + diff --git a/crates/upnp-serve/src/services/connection_manager.rs b/crates/upnp-serve/src/services/connection_manager.rs index 9b7817f..469d2d0 100644 --- a/crates/upnp-serve/src/services/connection_manager.rs +++ b/crates/upnp-serve/src/services/connection_manager.rs @@ -1,9 +1,11 @@ use axum::{body::Bytes, extract::State, response::IntoResponse}; use bstr::BStr; -use http::{HeaderMap, StatusCode}; +use http::{header::CONTENT_TYPE, HeaderMap, StatusCode}; use tracing::{debug, trace}; -use crate::{state::UnpnServerState, subscriptions::SubscribeRequest}; +use crate::{ + constants::CONTENT_TYPE_XML_UTF8, state::UnpnServerState, subscriptions::SubscribeRequest, +}; pub const SOAP_ACTION_GET_PROTOCOL_INFO: &[u8] = b"\"urn:schemas-upnp-org:service:ConnectionManager:1#GetProtocolInfo\""; @@ -39,7 +41,11 @@ pub(crate) async fn http_handler( let not_implemented = StatusCode::NOT_IMPLEMENTED.into_response(); match action.as_ref() { - SOAP_ACTION_GET_PROTOCOL_INFO => not_implemented, + SOAP_ACTION_GET_PROTOCOL_INFO => ( + [(CONTENT_TYPE, CONTENT_TYPE_XML_UTF8)], + include_str!("../resources/templates/connection_manager/control/get_protocol_info.xml"), + ) + .into_response(), SOAP_ACTION_CONNECTION_COMPLETE => not_implemented, SOAP_ACTION_GET_CURRENT_CONNECTION_INFO => not_implemented, SOAP_ACTION_GET_CURRENT_CONNECTION_IDS => not_implemented,