fix MDXMLINT-31

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9216 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-08-01 15:06:56 +00:00
parent 509562b401
commit d8816f7d73
2 changed files with 50 additions and 15 deletions

View File

@ -570,6 +570,7 @@ SWITCH_STANDARD_API(status_function)
switch_core_time_duration_t duration = { 0 }; switch_core_time_duration_t duration = { 0 };
char *http = NULL; char *http = NULL;
int sps = 0, last_sps = 0; int sps = 0, last_sps = 0;
const char *var;
if (session) { if (session) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -581,6 +582,14 @@ SWITCH_STANDARD_API(status_function)
http = switch_event_get_header(stream->param_event, "http-host"); http = switch_event_get_header(stream->param_event, "http-host");
} }
if ((var = switch_event_get_header(stream->param_event, "content-type"))) {
if (!strcasecmp(var, "text/plain")) {
http = NULL;
}
} else {
stream->write_function(stream, "%s", "Content-Type: text/html\n\n");
}
if (http || (cmd && strstr(cmd, "html"))) { if (http || (cmd && strstr(cmd, "html"))) {
html = 1; html = 1;
stream->write_function(stream, "<h1>FreeSWITCH Status</h1>\n<b>"); stream->write_function(stream, "<h1>FreeSWITCH Status</h1>\n<b>");
@ -2008,7 +2017,17 @@ SWITCH_STANDARD_API(show_function)
} }
if (stream->param_event) { if (stream->param_event) {
const char *var;
holder.http = switch_event_get_header(stream->param_event, "http-host"); holder.http = switch_event_get_header(stream->param_event, "http-host");
if ((var = switch_event_get_header(stream->param_event, "content-type"))) {
if (!strcasecmp(var, "text/plain")) {
holder.http = NULL;
}
} else {
stream->write_function(stream, "%s", "Content-Type: text/html\n\n");
}
} }
holder.print_title = 1; holder.print_title = 1;

View File

@ -158,6 +158,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
const char *box; const char *box;
int at = 0; int at = 0;
switch_event_t *params = NULL; switch_event_t *params = NULL;
char *dp;
p = RequestHeaderValue(r, "authorization"); p = RequestHeaderValue(r, "authorization");
@ -166,17 +167,20 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
x = GetToken(&p); x = GetToken(&p);
if (x) { if (x) {
if (!strcasecmp(x, "basic")) { if (!strcasecmp(x, "basic")) {
NextToken((const char **const) &p); NextToken((const char **const) &p);
switch_b64_decode(p, user, sizeof(user)); switch_b64_decode(p, user, sizeof(user));
if ((pass = strchr(user, ':'))) { if ((pass = strchr(user, ':'))) {
*pass++ = '\0'; *pass++ = '\0';
} }
if ((dp = strchr(user, '@'))) {
*dp++ = '\0';
domain_name = dp;
}
if (!domain_name) { if (!domain_name) {
if ((domain_name = strchr(user, '@'))) { if (dp) {
*domain_name++ = '\0'; domain_name = dp;
at++; at++;
} else { } else {
domain_name = (char *) r->requestInfo.host; domain_name = (char *) r->requestInfo.host;
@ -224,6 +228,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
} }
if (!(x_params = switch_xml_child(x_user, "params"))) { if (!(x_params = switch_xml_child(x_user, "params"))) {
r->requestInfo.user = strdup(user);
goto authed; goto authed;
} }
@ -307,6 +312,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
authed: authed:
if (r->requestInfo.user && domain_name) {
ResponseAddField(r, "freeswitch-user", r->requestInfo.user); ResponseAddField(r, "freeswitch-user", r->requestInfo.user);
ResponseAddField(r, "freeswitch-domain", domain_name); ResponseAddField(r, "freeswitch-domain", domain_name);
@ -318,6 +324,7 @@ static abyss_bool http_directory_auth(TSession * r, char *domain_name)
} }
} }
} }
}
fail: fail:
@ -437,7 +444,7 @@ abyss_bool handler_hook(TSession * r)
char *fs_user = NULL, *fs_domain = NULL; char *fs_user = NULL, *fs_domain = NULL;
char *path_info = NULL; char *path_info = NULL;
abyss_bool ret = TRUE; abyss_bool ret = TRUE;
int html = 0; int html = 0, text = 0;
stream.data = r; stream.data = r;
stream.write_function = http_stream_write; stream.write_function = http_stream_write;
@ -452,6 +459,9 @@ abyss_bool handler_hook(TSession * r)
} else if ((command = strstr(r->requestInfo.uri, "/webapi/"))) { } else if ((command = strstr(r->requestInfo.uri, "/webapi/"))) {
command += 8; command += 8;
html++; html++;
} else if ((command = strstr(r->requestInfo.uri, "/txtapi/"))) {
command += 8;
text++;
} else { } else {
return FALSE; return FALSE;
} }
@ -510,6 +520,10 @@ abyss_bool handler_hook(TSession * r)
if (switch_event_create(&stream.param_event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&stream.param_event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
const char *const content_length = RequestHeaderValue(r, "content-length"); const char *const content_length = RequestHeaderValue(r, "content-length");
if (html)
switch_event_add_header(stream.param_event, SWITCH_STACK_BOTTOM, "Content-type", "%s", "text/html");
else if (text)
switch_event_add_header(stream.param_event, SWITCH_STACK_BOTTOM, "Content-type", "%s", "text/plain");
if (fs_user) if (fs_user)
switch_event_add_header(stream.param_event, SWITCH_STACK_BOTTOM, "FreeSWITCH-User", "%s", fs_user); switch_event_add_header(stream.param_event, SWITCH_STACK_BOTTOM, "FreeSWITCH-User", "%s", fs_user);
if (fs_domain) if (fs_domain)
@ -633,6 +647,8 @@ abyss_bool handler_hook(TSession * r)
if (html) { if (html) {
ResponseAddField(r, "Content-Type", "text/html"); ResponseAddField(r, "Content-Type", "text/html");
} else if (text) {
ResponseAddField(r, "Content-Type", "text/plain");
} }
for (i = 0; i < r->response_headers.size; i++) { for (i = 0; i < r->response_headers.size; i++) {
@ -646,7 +662,7 @@ abyss_bool handler_hook(TSession * r)
switch_snprintf(buf, sizeof(buf), "Connection: close\r\n"); switch_snprintf(buf, sizeof(buf), "Connection: close\r\n");
ConnWrite(r->conn, buf, (uint32_t) strlen(buf)); ConnWrite(r->conn, buf, (uint32_t) strlen(buf));
if (html) { if (html || text) {
ConnWrite(r->conn, "\r\n", 2); ConnWrite(r->conn, "\r\n", 2);
} }