commit 3ebd3f2

uint  ·  2026-01-29 23:13:32 +0000 UTC
parent eb81dfb
remove /queue endpoint

not needed anymore
2 files changed,  +0, -86
+0, -85
  1@@ -27,11 +27,9 @@ static int parse_range(const char* hdr, size_t total, size_t* start, size_t* end
  2 static int read_request(int c, char* method, size_t msz, char* path, size_t psz, char* hdr, size_t hsz);
  3 static void reply(int c, const char* hdr, const char* status, const char* ctype, const char* extra, const void* body, size_t len, int send_body, int preflight);
  4 static void reply_json(int c, const char* hdr, const char* status, const char* body, size_t len, int send_body);
  5-static void reply_m3u(int c, const char* hdr, const char* status, size_t len);
  6 static void reply_preflight(int c, const char* hdr);
  7 static void reply_text(int c, const char* hdr, const char* status, const char* body);
  8 static void reply_unauth(int c, const char* hdr, int send_body);
  9-static int queue_write(int c, const char* hdr, int head_only, const struct user* u);
 10 static int stat_item(const struct item* it, struct stat* st);
 11 static int stream_file(int c, const struct item* it, const char* hdr, int head_only);
 12 
 13@@ -374,11 +372,6 @@ static void reply_json(int c, const char* hdr, const char* status, const char* b
 14 	reply(c, hdr, status, HTTP_JSON, NULL, body, len, send_body, 0);
 15 }
 16 
 17-static void reply_m3u(int c, const char* hdr, const char* status, size_t len)
 18-{
 19-	reply(c, hdr, status, HTTP_M3U, NULL, NULL, len, 0, 0);
 20-}
 21-
 22 static void reply_preflight(int c, const char* hdr)
 23 {
 24 	reply(c, hdr, HTTP_204, NULL, NULL, NULL, (size_t)0, 0, 1);
 25@@ -407,73 +400,6 @@ static void reply_unauth(int c, const char* hdr, int send_body)
 26 	);
 27 }
 28 
 29-static int queue_write(int c, const char* hdr, int head_only, const struct user* u)
 30-{
 31-	char host[512];
 32-	char base[768];
 33-
 34-	if (hdr_get_value(host, hdr, "host") == 0) {
 35-		if (snprintf(base, sizeof(base), "http://%s", host) >= (int)sizeof(base))
 36-			return -1;
 37-	}
 38-	else {
 39-		if (snprintf(base, sizeof(base), "http://%s:%d", server_addr, server_port) >= (int)sizeof(base))
 40-			return -1;
 41-	}
 42-
 43-	/* Content-Length */
 44-	size_t len = 0;
 45-	len += 8; /* "#EXTM3U\n" */
 46-
 47-	for (size_t i = 0; i < lib.len; i++) {
 48-		if (u && !user_allows_path(u, lib.items[i].path))
 49-			continue;
 50-
 51-		int n = snprintf(
 52-			NULL, 0,
 53-			"%s/stream/%016llx\n",
 54-			base,
 55-			(unsigned long long)lib.items[i].id
 56-		);
 57-
 58-		if (n < 0)
 59-			return -1;
 60-
 61-		len += (size_t)n;
 62-	}
 63-
 64-	reply_m3u(c, hdr, HTTP_200, len);
 65-
 66-	if (head_only)
 67-		return 0;
 68-
 69-	if (write_all(c, "#EXTM3U\n", 8) < 0)
 70-		return -1;
 71-
 72-	for (size_t i = 0; i < lib.len; i++) {
 73-		if (u && !user_allows_path(u, lib.items[i].path))
 74-			continue;
 75-
 76-		char line[2048];
 77-		int n = snprintf(
 78-			line, sizeof(line),
 79-			"%s/stream/%016llx\n",
 80-			base,
 81-			(unsigned long long)lib.items[i].id
 82-		);
 83-
 84-		if (n < 0)
 85-			return -1;
 86-		if ((size_t)n >= sizeof(line))
 87-			return -1;
 88-
 89-		if (write_all(c, line, (size_t)n) < 0)
 90-			return -1;
 91-	}
 92-
 93-	return 0;
 94-}
 95-
 96 static int stat_item(const struct item* it, struct stat* st)
 97 {
 98 	char full[4096];
 99@@ -789,17 +715,6 @@ int http_handle(int c)
100 		return 0;
101 	}
102 
103-	if (strcmp(path, "/queue") == 0) {
104-		LOG(verbose_log, "HTTP", "Route              /queue");
105-
106-		if (queue_write(c, hdr, head_only, u) < 0) {
107-			reply_text(c, hdr, HTTP_500, "server error\n");
108-			return -1;
109-		}
110-
111-		return 0;
112-	}
113-
114 	LOG(verbose_log, "HTTP", "Route not found    %s", path);
115 	reply_text(c, hdr, HTTP_404, "not found\n");
116 
+0, -1
1@@ -16,7 +16,6 @@
2 #define HTTP_CTYPE  "Content-Type: %s\r\n"
3 #define HTTP_JSON   "Content-Type: application/json\r\n"
4 #define HTTP_LENGTH "Content-Length: %zu\r\n"
5-#define HTTP_M3U    "Content-Type: audio/x-mpegurl\r\n"
6 #define HTTP_RANGE  "Accept-Ranges: bytes\r\n"
7 #define HTTP_TEXT   "Content-Type: text/plain\r\n"
8