From 5f082a2739087538d795e12c83f017e5480491b5 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Fri, 6 Jul 2018 17:28:01 +0200
Subject: [PATCH] output/httpd: remove broken DLNA support code

This code was added in 21851c06733080b4c131d553d5d1f8784c12410f but
looks completely broken:

- the status code is "206 OK" but "206" would be "Partial Content"

- the "Content-Length" header has a bogus value

- the "Content-RangeX" parameter has different bogus values (why
  "Content-RangeX" anyway and not "Content-Range"?)

Apart from that, there are strange undocumented non-standard headers
which are probably there to work around bugs/expectations in one
broken proprietary client product.  But these days, MPD doesn't bend
over to support broken clients.  So let's kill this code.

Closes #304
---
 NEWS                                     |  2 ++
 src/output/plugins/httpd/HttpdClient.cxx | 27 +-----------------------
 src/output/plugins/httpd/HttpdClient.hxx |  5 -----
 3 files changed, 3 insertions(+), 31 deletions(-)

diff --git a/NEWS b/NEWS
index 1b0fc1e59..8b8e6591a 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ ver 0.20.21 (not yet released)
 * database
   - proxy: add "password" setting
   - proxy: support tags "ArtistSort", "AlbumArtistSort", "AlbumSort"
+* output
+  - httpd: remove broken DLNA support code
 
 ver 0.20.20 (2018/05/22)
 * protocol
diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx
index d5a423d7d..9d3b38c16 100644
--- a/src/output/plugins/httpd/HttpdClient.cxx
+++ b/src/output/plugins/httpd/HttpdClient.cxx
@@ -122,15 +122,6 @@ HttpdClient::HandleLine(const char *line)
 			return true;
 		}
 
-		if (StringEqualsCaseASCII(line, "transferMode.dlna.org: Streaming", 32)) {
-			/* Send as dlna */
-			dlna_streaming_requested = true;
-			/* metadata is not supported by dlna streaming, so disable it */
-			metadata_supported = false;
-			metadata_requested = false;
-			return true;
-		}
-
 		/* expect more request headers */
 		return true;
 	}
@@ -148,22 +139,7 @@ HttpdClient::SendResponse()
 
 	assert(state == RESPONSE);
 
-	if (dlna_streaming_requested) {
-		snprintf(buffer, sizeof(buffer),
-			 "HTTP/1.1 206 OK\r\n"
-			 "Content-Type: %s\r\n"
-			 "Content-Length: 10000\r\n"
-			 "Content-RangeX: 0-1000000/1000000\r\n"
-			 "transferMode.dlna.org: Streaming\r\n"
-			 "Accept-Ranges: bytes\r\n"
-			 "Connection: close\r\n"
-			 "realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n"
-			 "contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n"
-			 "\r\n",
-			 httpd.content_type);
-		response = buffer;
-
-	} else if (metadata_requested) {
+	if (metadata_requested) {
 		allocated =
 			icy_server_metadata_header(httpd.name, httpd.genre,
 						   httpd.website,
@@ -202,7 +178,6 @@ HttpdClient::HttpdClient(HttpdOutput &_httpd, int _fd, EventLoop &_loop,
 	 state(REQUEST),
 	 queue_size(0),
 	 head_method(false),
-	 dlna_streaming_requested(false),
 	 metadata_supported(_metadata_supported),
 	 metadata_requested(false), metadata_sent(true),
 	 metaint(8192), /*TODO: just a std value */
diff --git a/src/output/plugins/httpd/HttpdClient.hxx b/src/output/plugins/httpd/HttpdClient.hxx
index 3cc337e94..a890833ba 100644
--- a/src/output/plugins/httpd/HttpdClient.hxx
+++ b/src/output/plugins/httpd/HttpdClient.hxx
@@ -82,11 +82,6 @@ class HttpdClient final
 	 */
 	bool head_method;
 
-	/**
-         * If DLNA streaming was an option.
-         */
-	bool dlna_streaming_requested;
-
 	/* ICY */
 
 	/**