提交 3d8f7815 authored 作者: Anthony Minessale's avatar Anthony Minessale

add no-cache support

上级 3768d802
...@@ -161,6 +161,8 @@ struct http_file_context { ...@@ -161,6 +161,8 @@ struct http_file_context {
time_t expires; time_t expires;
switch_file_t *lock_fd; switch_file_t *lock_fd;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
int del_on_close;
}; };
typedef struct http_file_context http_file_context_t; typedef struct http_file_context http_file_context_t;
...@@ -2013,7 +2015,8 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char ...@@ -2013,7 +2015,8 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char
const char *cc; const char *cc;
const char *p; const char *p;
if (headers && (cc = switch_event_get_header(headers, "Cache-Control")) && (p = switch_stristr("max-age=", cc))) { if (headers && (cc = switch_event_get_header(headers, "Cache-Control"))) {
if ((p = switch_stristr("max-age=", cc))) {
p += 8; p += 8;
if (!zstr(p)) { if (!zstr(p)) {
...@@ -2022,6 +2025,10 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char ...@@ -2022,6 +2025,10 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char
} }
} }
if (switch_stristr("no-cache", cc) || switch_stristr("no-store", cc)) {
context->del_on_close = 1;
}
}
switch_snprintf(write_data, sizeof(write_data), switch_snprintf(write_data, sizeof(write_data),
"%" SWITCH_TIME_T_FMT ":%s", "%" SWITCH_TIME_T_FMT ":%s",
...@@ -2206,6 +2213,14 @@ static switch_status_t http_file_file_close(switch_file_handle_t *handle) ...@@ -2206,6 +2213,14 @@ static switch_status_t http_file_file_close(switch_file_handle_t *handle)
switch_core_file_close(&context->fh); switch_core_file_close(&context->fh);
} }
if (context->del_on_close) {
if (context->cache_file) {
unlink(context->cache_file);
unlink(context->meta_file);
unlink(context->lock_file);
}
}
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论