Skip to content

Commit face9d3

Browse files
committed
Fix compilation with NgX 1.23+
Based on patch from #56 (comment)
1 parent 6a8a302 commit face9d3

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

ngx_http_uploadprogress_module.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,12 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
724724
ngx_chain_t out;
725725
ngx_int_t rc, found=0, done=0, err_status=0;
726726
off_t rest=0, length=0;
727-
ngx_uint_t len, i;
727+
ngx_uint_t len;
728728
ngx_slab_pool_t *shpool;
729729
ngx_http_uploadprogress_conf_t *upcf;
730730
ngx_http_uploadprogress_ctx_t *ctx;
731731
ngx_http_uploadprogress_node_t *up;
732-
ngx_table_elt_t *expires, *cc, **ccp;
732+
ngx_table_elt_t *expires, *cc;
733733
ngx_http_uploadprogress_state_t state;
734734
ngx_http_uploadprogress_template_t *t;
735735

@@ -778,6 +778,7 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
778778
}
779779

780780
r->headers_out.expires = expires;
781+
expires->next = NULL;
781782

782783
expires->hash = 1;
783784
expires->key.len = sizeof("Expires") - 1;
@@ -787,37 +788,28 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
787788
len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
788789
expires->value.len = len - 1;
789790

790-
ccp = r->headers_out.cache_control.elts;
791-
if (ccp == NULL) {
792-
793-
if (ngx_array_init(&r->headers_out.cache_control, r->pool,
794-
1, sizeof(ngx_table_elt_t *))
795-
!= NGX_OK) {
796-
return NGX_HTTP_INTERNAL_SERVER_ERROR;
797-
}
798-
799-
ccp = ngx_array_push(&r->headers_out.cache_control);
800-
if (ccp == NULL) {
801-
return NGX_HTTP_INTERNAL_SERVER_ERROR;
802-
}
803-
791+
cc = r->headers_out.cache_control;
792+
if (cc == NULL) {
804793
cc = ngx_list_push(&r->headers_out.headers);
805794
if (cc == NULL) {
795+
expires->hash = 0;
806796
return NGX_HTTP_INTERNAL_SERVER_ERROR;
807797
}
808798

799+
r->headers_out.cache_control = cc;
800+
cc->next = NULL;
801+
809802
cc->hash = 1;
810803
cc->key.len = sizeof("Cache-Control") - 1;
811804
cc->key.data = (u_char *) "Cache-Control";
812805

813-
*ccp = cc;
814-
815806
} else {
816-
for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
817-
ccp[i]->hash = 0;
807+
for (cc = cc->next; cc; cc = cc->next) {
808+
cc->hash = 0;
818809
}
819810

820-
cc = ccp[0];
811+
cc = r->headers_out.cache_control;
812+
cc->next = NULL;
821813
}
822814

823815
expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT";

0 commit comments

Comments
 (0)