Accidentially broke sdk and imagebuilder in [6857]
[openwrt.git] / package / busybox / patches / 350-httpd_redir.patch
1 diff -ur bb.old/include/usage.h bb.dev/include/usage.h
2 --- bb.old/include/usage.h 2007-03-29 13:25:55.080325000 +0200
3 +++ bb.dev/include/usage.h 2007-03-29 13:31:04.241326192 +0200
4 @@ -1333,7 +1333,8 @@
5 USE_FEATURE_HTTPD_BASIC_AUTH(" [-r <realm>]") \
6 USE_FEATURE_HTTPD_AUTH_MD5(" [-m pass]") \
7 " [-h home]" \
8 - " [-d/-e <string>]"
9 + " [-d/-e <string>]" \
10 + " [-R <path> [-H <host>]]"
11 #define httpd_full_usage \
12 "Listen for incoming http server requests" \
13 "\n\nOptions:\n" \
14 @@ -1349,7 +1350,9 @@
15 " -m PASS Crypt PASS with md5 algorithm\n") \
16 " -h HOME Specifies http HOME directory (default ./)\n" \
17 " -e STRING HTML encode STRING\n" \
18 - " -d STRING URL decode STRING"
19 + " -d STRING URL decode STRING\n" \
20 + " -R PATH Redirect target path\n" \
21 + " -H HOST Redirect target host"
22
23 #define hwclock_trivial_usage \
24 "[-r|--show] [-s|--hctosys] [-w|--systohc] [-l|--localtime] [-u|--utc]"
25 diff -ur bb.old/networking/httpd.c bb.dev/networking/httpd.c
26 --- bb.old/networking/httpd.c 2007-03-29 13:25:55.016335000 +0200
27 +++ bb.dev/networking/httpd.c 2007-03-29 13:40:05.353064704 +0200
28 @@ -141,6 +141,8 @@
29 USE_FEATURE_HTTPD_CGI(char *user_agent;)
30
31 const char *configFile;
32 + const char *redirectPath;
33 + const char *redirectHost;
34
35 unsigned int rmt_ip;
36 #if ENABLE_FEATURE_HTTPD_CGI || DEBUG
37 @@ -881,8 +883,11 @@
38 }
39 #endif
40 if (responseNum == HTTP_MOVED_TEMPORARILY) {
41 - len += sprintf(buf+len, "Location: %s/%s%s\r\n",
42 + len += sprintf(buf+len, "Location: %s%s%s%s%s%s\r\n",
43 + (config->redirectHost ? "http://" : ""),
44 + (config->redirectHost ? config->redirectHost : ""),
45 config->found_moved_temporarily,
46 + (config->redirectHost ? "" : "/"),
47 (config->query ? "?" : ""),
48 (config->query ? config->query : ""));
49 }
50 @@ -1598,8 +1603,12 @@
51 *++purl = '\0'; /* so keep last character */
52 test = purl; /* end ptr */
53
54 + /* redirect active */
55 + if (config->redirectPath && (strncmp(url, config->redirectPath, strlen(config->redirectPath)) != 0))
56 + config->found_moved_temporarily = config->redirectPath;
57 +
58 /* If URL is directory, adding '/' */
59 - if (test[-1] != '/') {
60 + if(!config->redirectPath && (test[-1] != '/')) {
61 if (is_directory(url + 1, 1, &sb)) {
62 config->found_moved_temporarily = url;
63 }
64 @@ -1901,7 +1910,9 @@
65 #endif
66
67 enum {
68 - c_opt_config_file = 0,
69 + R_opt_redirect_path = 0,
70 + H_opt_redirect_host,
71 + c_opt_config_file,
72 d_opt_decode_url,
73 h_opt_home_httpd,
74 USE_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
75 @@ -1923,7 +1934,7 @@
76 OPT_FOREGROUND = 1 << p_opt_foreground,
77 };
78
79 -static const char httpd_opts[] = "c:d:h:"
80 +static const char httpd_opts[] = "R:H:c:d:h:"
81 USE_FEATURE_HTTPD_ENCODE_URL_STR("e:")
82 USE_FEATURE_HTTPD_BASIC_AUTH("r:")
83 USE_FEATURE_HTTPD_AUTH_MD5("m:")
84 @@ -1954,6 +1965,7 @@
85 config->ContentLength = -1;
86
87 opt = getopt32(argc, argv, httpd_opts,
88 + &(config->redirectPath), &(config->redirectHost),
89 &(config->configFile), &url_for_decode, &home_httpd
90 USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
91 USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm))
This page took 0.072936 seconds and 5 git commands to generate.