Syntax: add_header name value [always]; Default: —
1 2 3 4 5
Context: http, server, location, if in location Syntax: add_trailer name value [always]; Default: — Context: http, server, location, if in location This directive appeared in version 1.13.2.
1 2 3 4 5 6
Syntax: expires [modified] time; expires epoch | max | off; Default: expires off; Context: http, server, location, if in location
case NGX_HTTP_OK: case NGX_HTTP_CREATED: case NGX_HTTP_NO_CONTENT: case NGX_HTTP_PARTIAL_CONTENT: case NGX_HTTP_MOVED_PERMANENTLY: case NGX_HTTP_MOVED_TEMPORARILY: case NGX_HTTP_SEE_OTHER: case NGX_HTTP_NOT_MODIFIED: case NGX_HTTP_TEMPORARY_REDIRECT: case NGX_HTTP_PERMANENT_REDIRECT: safe_status = 1; break;
default: safe_status = 0; break; }
if (conf->expires != NGX_HTTP_EXPIRES_OFF && safe_status) { if (ngx_http_set_expires(r, conf) != NGX_OK) { return NGX_ERROR; } }
if (conf->headers) { h = conf->headers->elts; for (i = 0; i < conf->headers->nelts; i++) {
if (!safe_status && !h[i].always) { continue; }
if (ngx_http_complex_value(r, &h[i].value, &value) != NGX_OK) { return NGX_ERROR; }
case NGX_HTTP_OK: case NGX_HTTP_CREATED: case NGX_HTTP_NO_CONTENT: case NGX_HTTP_PARTIAL_CONTENT: case NGX_HTTP_MOVED_PERMANENTLY: case NGX_HTTP_MOVED_TEMPORARILY: case NGX_HTTP_SEE_OTHER: case NGX_HTTP_NOT_MODIFIED: case NGX_HTTP_TEMPORARY_REDIRECT: case NGX_HTTP_PERMANENT_REDIRECT: safe_status = 1; break;
default: safe_status = 0; break; }
// 遍历配置的所有trailer h = conf->trailers->elts; for (i = 0; i < conf->trailers->nelts; i++) {
if (!safe_status && !h[i].always) { continue; }
if (ngx_http_complex_value(r, &h[i].value, &value) != NGX_OK) { return NGX_ERROR; }
if (value.len) { t = ngx_list_push(&r->headers_out.trailers); if (t == NULL) { return NGX_ERROR; }