mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 00:04:53 +00:00
Merged revisions 62414 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r62414 | russell | 2007-04-30 10:25:31 -0500 (Mon, 30 Apr 2007) | 4 lines 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) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@62415 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -152,7 +152,9 @@ struct ast_http_uri {
|
|||||||
AST_LIST_ENTRY(ast_http_uri) entry;
|
AST_LIST_ENTRY(ast_http_uri) entry;
|
||||||
const char *description;
|
const char *description;
|
||||||
const char *uri;
|
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;
|
ast_http_callback callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
16
main/http.c
16
main/http.c
@@ -274,6 +274,7 @@ static struct ast_http_uri staticuri = {
|
|||||||
.description = "Asterisk HTTP Static Delivery",
|
.description = "Asterisk HTTP Static Delivery",
|
||||||
.uri = "static",
|
.uri = "static",
|
||||||
.has_subtree = 1,
|
.has_subtree = 1,
|
||||||
|
.static_content = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ast_str *ast_http_error(int status, const char *title, const char *extra_header, const char *text)
|
struct ast_str *ast_http_error(int status, const char *title, const char *extra_header, const char *text)
|
||||||
@@ -562,7 +563,9 @@ static struct ast_str *handle_post(struct server_instance *ser, char *uri,
|
|||||||
return ast_http_error(200, "OK", NULL, "File successfully uploaded.");
|
return ast_http_error(200, "OK", NULL, "File successfully uploaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **title, int *contentlength, struct ast_variable **cookies)
|
static struct ast_str *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 *c;
|
||||||
struct ast_str *out = NULL;
|
struct ast_str *out = NULL;
|
||||||
@@ -644,6 +647,8 @@ static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *statu
|
|||||||
AST_RWLIST_UNLOCK(&uris);
|
AST_RWLIST_UNLOCK(&uris);
|
||||||
}
|
}
|
||||||
if (urih) {
|
if (urih) {
|
||||||
|
if (urih->static_content)
|
||||||
|
*static_content = 1;
|
||||||
out = urih->callback(sin, uri, vars, status, title, contentlength);
|
out = urih->callback(sin, uri, vars, status, title, contentlength);
|
||||||
AST_RWLIST_UNLOCK(&uris);
|
AST_RWLIST_UNLOCK(&uris);
|
||||||
} else {
|
} else {
|
||||||
@@ -757,6 +762,7 @@ static void *httpd_helper_thread(void *data)
|
|||||||
char *uri, *title=NULL;
|
char *uri, *title=NULL;
|
||||||
int status = 200, contentlength = 0;
|
int status = 200, contentlength = 0;
|
||||||
struct ast_str *out = NULL;
|
struct ast_str *out = NULL;
|
||||||
|
unsigned int static_content = 0;
|
||||||
|
|
||||||
if (!fgets(buf, sizeof(buf), ser->f))
|
if (!fgets(buf, sizeof(buf), ser->f))
|
||||||
goto done;
|
goto done;
|
||||||
@@ -850,7 +856,7 @@ static void *httpd_helper_thread(void *data)
|
|||||||
out = ast_http_error(501, "Not Implemented", NULL,
|
out = ast_http_error(501, "Not Implemented", NULL,
|
||||||
"Attempt to use unimplemented / unsupported method");
|
"Attempt to use unimplemented / unsupported method");
|
||||||
else /* try to serve it */
|
else /* try to serve it */
|
||||||
out = handle_uri(&ser->requestor, uri, &status, &title, &contentlength, &vars);
|
out = handle_uri(&ser->requestor, uri, &status, &title, &contentlength, &vars, &static_content);
|
||||||
|
|
||||||
/* If they aren't mopped up already, clean up the cookies */
|
/* If they aren't mopped up already, clean up the cookies */
|
||||||
if (vars)
|
if (vars)
|
||||||
@@ -866,8 +872,10 @@ static void *httpd_helper_thread(void *data)
|
|||||||
fprintf(ser->f, "HTTP/1.1 %d %s\r\n"
|
fprintf(ser->f, "HTTP/1.1 %d %s\r\n"
|
||||||
"Server: Asterisk/%s\r\n"
|
"Server: Asterisk/%s\r\n"
|
||||||
"Date: %s\r\n"
|
"Date: %s\r\n"
|
||||||
"Connection: close\r\n",
|
"Connection: close\r\n"
|
||||||
status, title ? title : "OK", ASTERISK_VERSION, timebuf);
|
"%s",
|
||||||
|
status, title ? title : "OK", ASTERISK_VERSION, timebuf,
|
||||||
|
static_content ? "" : "Cache-Control: no-cache, no-store\r\n");
|
||||||
if (!contentlength) { /* opaque body ? just dump it hoping it is properly formatted */
|
if (!contentlength) { /* opaque body ? just dump it hoping it is properly formatted */
|
||||||
fprintf(ser->f, "%s", out->str);
|
fprintf(ser->f, "%s", out->str);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user