summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2006-04-02 09:10:43 +0000
committerMark Spencer <markster@digium.com>2006-04-02 09:10:43 +0000
commitf69e6b9206b8153d9879ead1905a1b0c12e3f7b0 (patch)
tree1dff6f665b58d010969f15772c0453b955c690b8 /http.c
parent8a366ba988e63f57e659b847e8a791ca32e184ae (diff)
Properly handle empty prefix
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16939 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'http.c')
-rw-r--r--http.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/http.c b/http.c
index 5fcdc8ac9..2cd168862 100644
--- a/http.c
+++ b/http.c
@@ -278,8 +278,6 @@ static char *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **
struct ast_variable *vars=NULL, *v, *prev = NULL;
- if (*uri == '/')
- uri++;
params = strchr(uri, '?');
if (params) {
*params = '\0';
@@ -334,6 +332,11 @@ static char *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **
if (urih) {
c = urih->callback(sin, uri, vars, status, title, contentlength);
ast_variables_destroy(vars);
+ } else if (ast_strlen_zero(uri) && ast_strlen_zero(prefix)) {
+ /* Special case: If no prefix, and no URI, send to /static/index.html */
+ c = ast_http_error(302, "Moved Temporarily", "Location: /static/index.html\r\n", "This is not the page you are looking for...");
+ *status = 302;
+ *title = strdup("Moved Temporarily");
} else {
c = ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this serer.");
*status = 404;
@@ -586,8 +589,15 @@ static int __ast_http_load(int reload)
} else {
ast_log(LOG_WARNING, "Invalid bind address '%s'\n", v->value);
}
- } else if (!strcasecmp(v->name, "prefix"))
- ast_copy_string(newprefix, v->value, sizeof(newprefix));
+ } else if (!strcasecmp(v->name, "prefix")) {
+ if (!ast_strlen_zero(v->value)) {
+ newprefix[0] = '/';
+ ast_copy_string(newprefix + 1, v->value, sizeof(newprefix) - 1);
+ } else {
+ newprefix[0] = '\0';
+ }
+
+ }
v = v->next;
}
ast_config_destroy(cfg);
@@ -620,7 +630,7 @@ static int handle_show_http(int fd, int argc, char *argv[])
ast_cli(fd, "Enabled URI's:\n");
urih = uris;
while(urih){
- ast_cli(fd, "/%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
+ ast_cli(fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
urih = urih->next;
}
if (!uris)