diff options
Diffstat (limited to 'src/nxt_http_static.c')
| -rw-r--r-- | src/nxt_http_static.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c index 67591595..bff7e12d 100644 --- a/src/nxt_http_static.c +++ b/src/nxt_http_static.c @@ -5,6 +5,7 @@ #include <nxt_router.h> #include <nxt_http.h> +#include <nxt_http_compression.h> typedef struct { @@ -326,6 +327,8 @@ nxt_http_static_send(nxt_task_t *task, nxt_http_request_t *r, nxt_work_handler_t body_handler; nxt_http_static_conf_t *conf; + printf("%s: \n", __func__); + action = ctx->action; conf = action->u.conf; rtcf = r->conf->socket_conf->router_conf; @@ -576,7 +579,34 @@ nxt_http_static_send(nxt_task_t *task, nxt_http_request_t *r, field->value_length = mtype->length; } + r->resp.mime_type = mtype; + if (ctx->need_body && nxt_file_size(&fi) > 0) { + ret = nxt_http_comp_check_compression(task, r); + if (ret != NXT_OK) { + goto fail; + } + + if (nxt_http_comp_wants_compression()) { + size_t out_total; + nxt_int_t ret; + + ret = nxt_http_comp_compress_static_response( + task, &f, &fi, + NXT_HTTP_STATIC_BUF_SIZE, + &out_total); + if (ret == NXT_ERROR) { + goto fail; + } + + ret = nxt_file_info(f, &fi); + if (nxt_slow_path(ret != NXT_OK)) { + goto fail; + } + + r->resp.content_length_n = out_total; + } + fb = nxt_mp_zget(r->mem_pool, NXT_BUF_FILE_SIZE); if (nxt_slow_path(fb == NULL)) { goto fail; @@ -793,6 +823,8 @@ nxt_http_static_body_handler(nxt_task_t *task, void *obj, void *data) nxt_work_queue_t *wq; nxt_http_request_t *r; + printf("%s: \n", __func__); + r = obj; fb = r->out; @@ -853,6 +885,8 @@ nxt_http_static_buf_completion(nxt_task_t *task, void *obj, void *data) nxt_off_t rest; nxt_http_request_t *r; + printf("%s: \n", __func__); + b = obj; r = data; |
