Sfoglia il codice sorgente

xcap_server: set content-type per auid in reply

- accept also xcap-caps auid
root 15 anni fa
parent
commit
406f43b42f
2 ha cambiato i file con 21 aggiunte e 2 eliminazioni
  1. 4 0
      modules_k/xcap_server/xcap_misc.c
  2. 17 2
      modules_k/xcap_server/xcap_server.c

+ 4 - 0
modules_k/xcap_server/xcap_misc.c

@@ -145,6 +145,10 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri)
 		LM_DBG("matched resource-lists\n");
 		xuri->type = RESOURCE_LIST;
 		xuri->auid.len = 14;
+	} else if(s.len>10 && strncmp(s.s, "xcap-caps/", 10)==0) {
+		LM_DBG("matched xcap-caps\n");
+		xuri->type = XCAP_CAPS;
+		xuri->auid.len = 9;
 	} else {
 		LM_ERR("unsupported auid in [%.*s]\n", xuri->uri.len,
 				xuri->uri.s);

+ 17 - 2
modules_k/xcap_server/xcap_server.c

@@ -403,6 +403,13 @@ static str xcaps_str_ok         = {"OK", 2};
 static str xcaps_str_srverr     = {"Server error", 12};
 static str xcaps_str_nocontent  = {"No content", 10};
 static str xcaps_str_appxml     = {"application/xml", 15};
+static str xcaps_str_apprlxml   = {"application/resource-lists+xml", 30};
+static str xcaps_str_apprsxml   = {"application/rls-services+xml", 28};
+#if 0
+static str xcaps_str_appxcxml   = {"application/xcap-caps+xml", 25};
+#endif
+static str xcaps_str_appapxml   = {"application/auth-policy+xml", 27};
+
 
 /**
  *
@@ -721,6 +728,7 @@ static int w_xcaps_get(sip_msg_t* msg, char* puri, char* ppath)
 	str body;
 	int ret = 0;
 	xcap_uri_t xuri;
+	str *ctype;
 
 	if(puri==0 || ppath==0)
 	{
@@ -771,11 +779,18 @@ static int w_xcaps_get(sip_msg_t* msg, char* puri, char* ppath)
 	if(ret==0)
 	{
 		/* doc found */
+		ctype = &xcaps_str_appxml;
+		if(xuri.type==RESOURCE_LIST)
+			ctype = &xcaps_str_apprlxml;
+		else if(xuri.type==PRES_RULES)
+			ctype = &xcaps_str_appapxml;
+		else if(xuri.type==RLS_SERVICE)
+			ctype = &xcaps_str_apprsxml;
 		xcaps_send_reply(msg, 200, &xcaps_str_ok, &etag,
-				&xcaps_str_appxml, &body);
+				ctype, &body);
 	} else {
 		/* doc not found */
-		xcaps_send_reply(msg, 204, &xcaps_str_nocontent, &xcaps_str_empty,
+		xcaps_send_reply(msg, 200, &xcaps_str_nocontent, &xcaps_str_empty,
 				&xcaps_str_empty, &xcaps_str_empty);
 	}
 	return 1;