[prev in list] [next in list] [prev in thread] [next in thread] 

List:       asterisk-commits
Subject:    [asterisk-commits] russell: branch 1.4 r62414 - in /branches/1.4:
From:       asterisk-commits () lists ! digium ! com
Date:       2007-04-30 15:25:31
Message-ID: 20070430152532.19461A948EA () lists ! digium ! internal
[Download RAW message or body]

Author: russell
Date: Mon Apr 30 10:25:31 2007
New Revision: 62414

URL: http://svn.digium.com/view/asterisk?view=rev&rev=62414
Log:
When serving dynamic content, include a Cache-Control header to instruct the
browsers to not store the resulting content.  
(issue #9621, reported by Pari, patch by me)

Modified:
    branches/1.4/include/asterisk/http.h
    branches/1.4/main/http.c

Modified: branches/1.4/include/asterisk/http.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/http.h?view=diff&rev=62414&r1=62413&r2=62414
 ==============================================================================
--- branches/1.4/include/asterisk/http.h (original)
+++ branches/1.4/include/asterisk/http.h Mon Apr 30 10:25:31 2007
@@ -42,7 +42,9 @@
 	struct ast_http_uri *next;
 	const char *description;
 	const char *uri;
-	int has_subtree;
+	unsigned int has_subtree:1;
+	/*! This URI mapping serves static content */
+	unsigned int static_content:1;
 	ast_http_callback callback;
 };
 

Modified: branches/1.4/main/http.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/http.c?view=diff&rev=62414&r1=62413&r2=62414
 ==============================================================================
--- branches/1.4/main/http.c (original)
+++ branches/1.4/main/http.c Mon Apr 30 10:25:31 2007
@@ -225,6 +225,7 @@
 	.description = "Asterisk HTTP Static Delivery",
 	.uri = "static",
 	.has_subtree = 1,
+	.static_content = 1,
 };
 	
 char *ast_http_error(int status, const char *title, const char *extra_header, const \
char *text) @@ -291,7 +292,9 @@
 	ast_rwlock_unlock(&uris_lock);
 }
 
-static char *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char \
**title, int *contentlength, struct ast_variable **cookies) +static char \
*handle_uri(struct sockaddr_in *sin, char *uri, int *status,  +	char **title, int \
*contentlength, struct ast_variable **cookies,  +	unsigned int *static_content)
 {
 	char *c;
 	char *turi;
@@ -358,6 +361,8 @@
 		}
 	}
 	if (urih) {
+		if (urih->static_content)
+			*static_content = 1;
 		c = urih->callback(sin, uri, vars, status, title, contentlength);
 		ast_rwlock_unlock(&uris_lock);
 	} else if (ast_strlen_zero(uri) && ast_strlen_zero(prefix)) {
@@ -385,6 +390,7 @@
 	char *vname, *vval;
 	int status = 200, contentlength = 0;
 	time_t t;
+	unsigned int static_content = 0;
 
 	if (fgets(buf, sizeof(buf), ser->f)) {
 		/* Skip method */
@@ -468,7 +474,7 @@
 
 		if (*uri) {
 			if (!strcasecmp(buf, "get")) 
-				c = handle_uri(&ser->requestor, uri, &status, &title, &contentlength, &vars);
+				c = handle_uri(&ser->requestor, uri, &status, &title, &contentlength, &vars, \
&static_content);  else 
 				c = ast_http_error(501, "Not Implemented", NULL, "Attempt to use unimplemented / \
unsupported method");\  } else 
@@ -487,6 +493,8 @@
 			ast_cli(ser->fd, "Server: Asterisk/%s\r\n", ASTERISK_VERSION);
 			ast_cli(ser->fd, "Date: %s\r\n", timebuf);
 			ast_cli(ser->fd, "Connection: close\r\n");
+			if (!static_content)
+				ast_cli(ser->fd, "Cache-Control: no-cache, no-store\r\n");
 			if (contentlength) {
 				char *tmp;
 				tmp = strstr(c, "\r\n\r\n");

_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

asterisk-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic