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
5 USE_FEATURE_HTTPD_BASIC_AUTH(" [-r <realm>]") \
6 USE_FEATURE_HTTPD_AUTH_MD5(" [-m pass]") \
9 + " [-d/-e <string>]" \
10 + " [-R <path> [-H <host>]]"
11 #define httpd_full_usage \
12 "Listen for incoming http server requests" \
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"
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
29 USE_FEATURE_HTTPD_CGI(char *user_agent;)
31 const char *configFile;
32 + const char *redirectPath;
33 + const char *redirectHost;
36 #if ENABLE_FEATURE_HTTPD_CGI || DEBUG
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 : ""));
50 @@ -1598,8 +1603,12 @@
51 *++purl = '\0'; /* so keep last character */
52 test = purl; /* end ptr */
54 + /* redirect active */
55 + if (config->redirectPath && (strncmp(url, config->redirectPath, strlen(config->redirectPath)) != 0))
56 + config->found_moved_temporarily = config->redirectPath;
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;
68 - c_opt_config_file = 0,
69 + R_opt_redirect_path = 0,
70 + H_opt_redirect_host,
74 USE_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
76 OPT_FOREGROUND = 1 << p_opt_foreground,
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:")
85 config->ContentLength = -1;
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))