[svn-commits] twilson: trunk r270660 - /trunk/res/res_phoneprov.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 15 16:10:20 CDT 2010


Author: twilson
Date: Tue Jun 15 16:10:15 2010
New Revision: 270660

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=270660
Log:
Don't send files twice and remove extra \r\n from header

After the manager http auth changes, we forgot to remove the manual
sending of the file. Also, ast_http_send adds two \r\n to the header that
is passed to it, so a trailing \r\n is removed from the Content-type
header. It might be better to change ast_http_send, but I don't like changing
the behavior of an API function.

(closes issue #17239)
Reported by: cjacobsen
Patches: 
      patch2.diff uploaded by cjacobsen (license 1029)
Tested by: lathama, cjacobsen


Modified:
    trunk/res/res_phoneprov.c

Modified: trunk/res/res_phoneprov.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_phoneprov.c?view=diff&rev=270660&r1=270659&r2=270660
==============================================================================
--- trunk/res/res_phoneprov.c (original)
+++ trunk/res/res_phoneprov.c Tue Jun 15 16:10:15 2010
@@ -411,7 +411,6 @@
 	char *file = NULL;
 	int len;
 	int fd;
-	char buf[256];
 	struct ast_str *http_header;
 
 	if (method != AST_HTTP_GET && method != AST_HTTP_HEAD) {
@@ -441,21 +440,11 @@
 		}
 
 		http_header = ast_str_create(80);
-		ast_str_set(&http_header, 0, "Content-type: %s\r\n",
+		ast_str_set(&http_header, 0, "Content-type: %s",
 			route->file->mime_type);
 
-		while ((len = read(fd, buf, sizeof(buf))) > 0) {
-			if (fwrite(buf, 1, len, ser->f) != len) {
-				if (errno != EPIPE) {
-					ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
-				} else {
-					ast_debug(3, "Requester closed the connection while downloading '%s'\n", path);
-				}
-				break;
-			}
-		}
-
 		ast_http_send(ser, method, 200, NULL, http_header, NULL, fd, 0);
+
 		close(fd);
 		route = unref_route(route);
 		return 0;
@@ -515,7 +504,7 @@
 		}
 
 		http_header = ast_str_create(80);
-		ast_str_set(&http_header, 0, "Content-type: %s\r\n",
+		ast_str_set(&http_header, 0, "Content-type: %s",
 			route->file->mime_type);
 
 		if (!(result = ast_str_create(512))) {




More information about the svn-commits mailing list