[Freeswitch-branches] [commit] r11419 - in freeswitch/branches/1.0/src/mod: applications/mod_conference xml_int/mod_xml_rpc

FreeSWITCH SVN mikej at freeswitch.org
Thu Jan 22 14:31:52 PST 2009


Author: mikej
Date: Thu Jan 22 16:31:52 2009
New Revision: 11419

Log:
mod_xml_rpc: fix http content types sent in responses (r:11099,11148,11150)

Modified:
   freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/1.0/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c

Modified: freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/1.0/src/mod/applications/mod_conference/mod_conference.c	Thu Jan 22 16:31:52 2009
@@ -3895,7 +3895,7 @@
 {
 	char *lbuf = NULL;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-	char *http = NULL;
+	char *http = NULL, *type = NULL;
 	int argc;
 	char *argv[25] = { 0 };
 
@@ -3905,11 +3905,14 @@
 
 	if (stream->param_event) {
 		http = switch_event_get_header(stream->param_event, "http-host");
+		type = switch_event_get_header(stream->param_event, "content-type");
 	}
 
 	if (http) {
 		/* Output must be to a web browser */
-		stream->write_function(stream, "<pre>\n");
+		if (type && !strcasecmp(type, "text/html")) {
+			stream->write_function(stream, "<pre>\n");
+		}
 	}
 
 	if (!(lbuf = strdup(cmd))) {

Modified: freeswitch/branches/1.0/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
==============================================================================
--- freeswitch/branches/1.0/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	(original)
+++ freeswitch/branches/1.0/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	Thu Jan 22 16:31:52 2009
@@ -449,7 +449,7 @@
 	char *fs_user = NULL, *fs_domain = NULL;
 	char *path_info = NULL;
 	abyss_bool ret = TRUE;
-	int html = 0, text = 0;
+	int html = 0, text = 0, xml = 0;
 
 	stream.data = r;
 	stream.write_function = http_stream_write;
@@ -467,6 +467,9 @@
 	} else if ((command = strstr(r->requestInfo.uri, "/txtapi/"))) {
 		command += 8;
 		text++;
+	} else if ((command = strstr(r->requestInfo.uri, "/xmlapi/"))) {
+		command += 8;
+		xml++;
 	} else {
 		return FALSE;
 	}
@@ -529,13 +532,15 @@
 			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "Content-type", "text/html");
 		else if (text)
 			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "Content-type", "text/plain");
+		else if (xml)
+			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "Content-type", "text/xml");
 		if (fs_user)
 			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "FreeSWITCH-User", fs_user);
 		if (fs_domain)
 			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Domain", fs_domain);
 		if (path_info)
 			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-Path-Info", path_info);
-		switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-URI", r->requestInfo.uri);
+			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-URI", r->requestInfo.uri);
 		if (r->requestInfo.query)
 			switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-QUERY", r->requestInfo.query);
 		if (r->requestInfo.host)
@@ -654,6 +659,8 @@
 		ResponseAddField(r, "Content-Type", "text/html");
 	} else if (text) {
 		ResponseAddField(r, "Content-Type", "text/plain");
+	} else if (xml) {
+		ResponseAddField(r, "Content-Type", "text/xml");
 	}
 
 	for (i = 0; i < r->response_headers.size; i++) {
@@ -667,7 +674,7 @@
 	switch_snprintf(buf, sizeof(buf), "Connection: close\r\n");
 	ConnWrite(r->conn, buf, (uint32_t) strlen(buf));
 
-	if (html || text) {
+	if (html || text || xml) {
 		ConnWrite(r->conn, "\r\n", 2);
 	}
 



More information about the Freeswitch-branches mailing list