diff options
| author | 2024-11-07 20:47:37 +0100 | |
|---|---|---|
| committer | 2024-11-07 20:47:37 +0100 | |
| commit | a6bf1ee0d0e238cb13d916c019bc231986d44401 (patch) | |
| tree | 5b37f54ed7818854febae4fdf656e1a4a2b16076 | |
| parent | Don't proxy our own URLs. (diff) | |
| download | penes-snac2-a6bf1ee0d0e238cb13d916c019bc231986d44401.tar.gz penes-snac2-a6bf1ee0d0e238cb13d916c019bc231986d44401.tar.xz penes-snac2-a6bf1ee0d0e238cb13d916c019bc231986d44401.zip | |
Use the raw_path for proxying (as some media may include ? arguments).
| -rw-r--r-- | html.c | 8 | ||||
| -rw-r--r-- | xs_fcgi.h | 2 | ||||
| -rw-r--r-- | xs_httpd.h | 1 |
3 files changed, 10 insertions, 1 deletions
| @@ -3216,7 +3216,13 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3216 | status = HTTP_STATUS_UNAUTHORIZED; | 3216 | status = HTTP_STATUS_UNAUTHORIZED; |
| 3217 | } | 3217 | } |
| 3218 | else { | 3218 | else { |
| 3219 | xs *url = xs_replace(p_path, "proxy/", "https:/" "/"); | 3219 | /* pick the raw path (including optional ? arguments) */ |
| 3220 | const char *raw_path = xs_dict_get(req, "raw_path"); | ||
| 3221 | |||
| 3222 | /* skip to where the proxy/ string starts */ | ||
| 3223 | raw_path += xs_str_in(raw_path, "proxy/"); | ||
| 3224 | |||
| 3225 | xs *url = xs_replace(raw_path, "proxy/", "https:/" "/"); | ||
| 3220 | xs *hdrs = xs_dict_new(); | 3226 | xs *hdrs = xs_dict_new(); |
| 3221 | 3227 | ||
| 3222 | hdrs = xs_dict_append(hdrs, "user-agent", USER_AGENT); | 3228 | hdrs = xs_dict_append(hdrs, "user-agent", USER_AGENT); |
| @@ -179,6 +179,8 @@ xs_dict *xs_fcgi_request(FILE *f, xs_str **payload, int *p_size, int *fcgi_id) | |||
| 179 | req = xs_dict_append(req, "method", v); | 179 | req = xs_dict_append(req, "method", v); |
| 180 | else | 180 | else |
| 181 | if (strcmp(k, "REQUEST_URI") == 0) { | 181 | if (strcmp(k, "REQUEST_URI") == 0) { |
| 182 | req = xs_dict_append(req, "raw_path", v); | ||
| 183 | |||
| 182 | xs *pnv = xs_split_n(v, "?", 1); | 184 | xs *pnv = xs_split_n(v, "?", 1); |
| 183 | 185 | ||
| 184 | /* store the path */ | 186 | /* store the path */ |
| @@ -32,6 +32,7 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size) | |||
| 32 | xs_dict *req = xs_dict_new(); | 32 | xs_dict *req = xs_dict_new(); |
| 33 | 33 | ||
| 34 | req = xs_dict_append(req, "method", xs_list_get(l2, 0)); | 34 | req = xs_dict_append(req, "method", xs_list_get(l2, 0)); |
| 35 | req = xs_dict_append(req, "raw_path", xs_list_get(l2, 1)); | ||
| 35 | req = xs_dict_append(req, "proto", xs_list_get(l2, 2)); | 36 | req = xs_dict_append(req, "proto", xs_list_get(l2, 2)); |
| 36 | 37 | ||
| 37 | { | 38 | { |