aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-11-07 20:47:37 +0100
committerdefault <nobody@localhost>2024-11-07 20:47:37 +0100
commita6bf1ee0d0e238cb13d916c019bc231986d44401 (patch)
tree5b37f54ed7818854febae4fdf656e1a4a2b16076
parente4e58d22224d37b9db760eda5bb25a76c3eea5b2 (diff)
Use the raw_path for proxying (as some media may include ? arguments).
-rw-r--r--html.c8
-rw-r--r--xs_fcgi.h2
-rw-r--r--xs_httpd.h1
3 files changed, 10 insertions, 1 deletions
diff --git a/html.c b/html.c
index c87883d..5d379e8 100644
--- a/html.c
+++ b/html.c
@@ -3216,7 +3216,13 @@ int html_get_handler(const xs_dict *req, const char *q_path,
status = HTTP_STATUS_UNAUTHORIZED;
}
else {
- xs *url = xs_replace(p_path, "proxy/", "https:/" "/");
+ /* pick the raw path (including optional ? arguments) */
+ const char *raw_path = xs_dict_get(req, "raw_path");
+
+ /* skip to where the proxy/ string starts */
+ raw_path += xs_str_in(raw_path, "proxy/");
+
+ xs *url = xs_replace(raw_path, "proxy/", "https:/" "/");
xs *hdrs = xs_dict_new();
hdrs = xs_dict_append(hdrs, "user-agent", USER_AGENT);
diff --git a/xs_fcgi.h b/xs_fcgi.h
index 6d3b030..c79121f 100644
--- a/xs_fcgi.h
+++ b/xs_fcgi.h
@@ -179,6 +179,8 @@ xs_dict *xs_fcgi_request(FILE *f, xs_str **payload, int *p_size, int *fcgi_id)
req = xs_dict_append(req, "method", v);
else
if (strcmp(k, "REQUEST_URI") == 0) {
+ req = xs_dict_append(req, "raw_path", v);
+
xs *pnv = xs_split_n(v, "?", 1);
/* store the path */
diff --git a/xs_httpd.h b/xs_httpd.h
index 02b8ac2..860ae05 100644
--- a/xs_httpd.h
+++ b/xs_httpd.h
@@ -32,6 +32,7 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size)
xs_dict *req = xs_dict_new();
req = xs_dict_append(req, "method", xs_list_get(l2, 0));
+ req = xs_dict_append(req, "raw_path", xs_list_get(l2, 1));
req = xs_dict_append(req, "proto", xs_list_get(l2, 2));
{