.description = "Asterisk HTTP Static Delivery",
.uri = "static",
.has_subtree = 1,
+ .static_content = 1,
};
struct ast_str *ast_http_error(int status, const char *title, const char *extra_header, const char *text)
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;
struct ast_str *out = NULL;
AST_RWLIST_UNLOCK(&uris);
}
if (urih) {
+ if (urih->static_content)
+ *static_content = 1;
out = urih->callback(sin, uri, vars, status, title, contentlength);
AST_RWLIST_UNLOCK(&uris);
} else {
char *uri, *title=NULL;
int status = 200, contentlength = 0;
struct ast_str *out = NULL;
+ unsigned int static_content = 0;
if (!fgets(buf, sizeof(buf), ser->f))
goto done;
out = ast_http_error(501, "Not Implemented", NULL,
"Attempt to use unimplemented / unsupported method");
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 (vars)
fprintf(ser->f, "HTTP/1.1 %d %s\r\n"
"Server: Asterisk/%s\r\n"
"Date: %s\r\n"
- "Connection: close\r\n",
- status, title ? title : "OK", ASTERISK_VERSION, timebuf);
+ "Connection: close\r\n"
+ "%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 */
fprintf(ser->f, "%s", out->str);
} else {