commit a6bf1ee

default  ·  2024-11-07 19:47:37 +0000 UTC
parent e4e58d2
Use the raw_path for proxying (as some media may include ? arguments).
3 files changed,  +10, -1
M html.c
M html.c
+7, -1
 1@@ -3216,7 +3216,13 @@ int html_get_handler(const xs_dict *req, const char *q_path,
 2             status = HTTP_STATUS_UNAUTHORIZED;
 3         }
 4         else {
 5-            xs *url = xs_replace(p_path, "proxy/", "https:/" "/");
 6+            /* pick the raw path (including optional ? arguments) */
 7+            const char *raw_path = xs_dict_get(req, "raw_path");
 8+
 9+            /* skip to where the proxy/ string starts */
10+            raw_path += xs_str_in(raw_path, "proxy/");
11+
12+            xs *url = xs_replace(raw_path, "proxy/", "https:/" "/");
13             xs *hdrs = xs_dict_new();
14 
15             hdrs = xs_dict_append(hdrs, "user-agent", USER_AGENT);
+2, -0
1@@ -179,6 +179,8 @@ xs_dict *xs_fcgi_request(FILE *f, xs_str **payload, int *p_size, int *fcgi_id)
2                         req = xs_dict_append(req, "method", v);
3                     else
4                     if (strcmp(k, "REQUEST_URI") == 0) {
5+                        req = xs_dict_append(req, "raw_path", v);
6+
7                         xs *pnv = xs_split_n(v, "?", 1);
8 
9                         /* store the path */
+1, -0
1@@ -32,6 +32,7 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size)
2     xs_dict *req = xs_dict_new();
3 
4     req = xs_dict_append(req, "method", xs_list_get(l2, 0));
5+    req = xs_dict_append(req, "raw_path", xs_list_get(l2, 1));
6     req = xs_dict_append(req, "proto",  xs_list_get(l2, 2));
7 
8     {