[asterisk-commits] twilson: trunk r135235 - in /trunk: main/http.c res/res_http_post.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 1 16:56:08 CDT 2008


Author: twilson
Date: Fri Aug  1 16:56:07 2008
New Revision: 135235

URL: http://svn.digium.com/view/asterisk?view=rev&rev=135235
Log:
Fix mime parsing by re-adding support for passing headers to callback functions

Modified:
    trunk/main/http.c
    trunk/res/res_http_post.c

Modified: trunk/main/http.c
URL: http://svn.digium.com/view/asterisk/trunk/main/http.c?view=diff&rev=135235&r1=135234&r2=135235
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Fri Aug  1 16:56:07 2008
@@ -657,6 +657,7 @@
 	int status = 200, contentlength = 0;
 	struct ast_str *out = NULL;
 	unsigned int static_content = 0;
+	struct ast_variable *tail = headers;
 
 	if (!fgets(buf, sizeof(buf), ser->f)) {
 		goto done;
@@ -686,6 +687,24 @@
 		}
 		if (!strncasecmp(cookie, "Cookie: ", 8)) {
 			vars = parse_cookies(cookie);
+		} else {
+			char *name, *val;
+
+			val = cookie;
+			name = strsep(&val, ":");
+			if (ast_strlen_zero(name) || ast_strlen_zero(val)) {
+				continue;
+			}
+			ast_trim_blanks(name);
+			val = ast_skip_blanks(val);
+
+			if (!headers) {
+				headers = ast_variable_new(name, val, __FILE__);
+				tail = headers;
+			} else {
+				tail->next = ast_variable_new(name, val, __FILE__);
+				tail = tail->next;
+			}
 		}
 	}
 

Modified: trunk/res/res_http_post.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_http_post.c?view=diff&rev=135235&r1=135234&r2=135235
==============================================================================
--- trunk/res/res_http_post.c (original)
+++ trunk/res/res_http_post.c Fri Aug  1 16:56:07 2008
@@ -203,6 +203,8 @@
 	}
 
 	for (var = headers; var; var = var->next) {
+		fprintf(f, "%s: %s\r\n", var->name, var->value);
+
 		if (!strcasecmp(var->name, "Content-Length")) {
 			if ((sscanf(var->value, "%u", &content_len)) != 1) {
 				ast_log(LOG_ERROR, "Invalid Content-Length in POST request!\n");
@@ -211,10 +213,10 @@
 				return NULL;
 			}
 			ast_debug(1, "Got a Content-Length of %d\n", content_len);
-		} else if (!strcasecmp(var->name, "Content-Type")) {
-			fprintf(f, "Content-Type: %s\r\n\r\n", var->value);
-		}
-	}
+		}
+	}
+
+	fprintf(f, "\r\n");
 
 	for (res = sizeof(buf); content_len; content_len -= res) {
 		if (content_len < res) {




More information about the asterisk-commits mailing list