Mercurial > hg > ngx_http_delay_body_filter_module
comparison ngx_http_delay_body_filter_module.c @ 3:53cbdb610633 default tip
Fixed error handling.
Request body filters are not allowed to return NGX_ERROR, they are
expected to use NGX_HTTP_* errors, notably NGX_HTTP_INTERNAL_SERVER_ERROR.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 26 Aug 2021 04:46:49 +0300 |
parents | b049c3a0543e |
children |
comparison
equal
deleted
inserted
replaced
2:b049c3a0543e | 3:53cbdb610633 |
---|---|
97 ctx = ngx_http_get_module_ctx(r, ngx_http_delay_body_filter_module); | 97 ctx = ngx_http_get_module_ctx(r, ngx_http_delay_body_filter_module); |
98 | 98 |
99 if (ctx == NULL) { | 99 if (ctx == NULL) { |
100 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_delay_body_ctx_t)); | 100 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_delay_body_ctx_t)); |
101 if (ctx == NULL) { | 101 if (ctx == NULL) { |
102 return NGX_ERROR; | 102 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
103 } | 103 } |
104 | 104 |
105 ngx_http_set_ctx(r, ctx, ngx_http_delay_body_filter_module); | 105 ngx_http_set_ctx(r, ctx, ngx_http_delay_body_filter_module); |
106 | 106 |
107 r->request_body->filter_need_buffering = 1; | 107 r->request_body->filter_need_buffering = 1; |
108 } | 108 } |
109 | 109 |
110 if (ngx_chain_add_copy(r->pool, &ctx->out, in) != NGX_OK) { | 110 if (ngx_chain_add_copy(r->pool, &ctx->out, in) != NGX_OK) { |
111 return NGX_ERROR; | 111 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
112 } | 112 } |
113 | 113 |
114 if (!ctx->event.timedout) { | 114 if (!ctx->event.timedout) { |
115 if (!ctx->event.timer_set) { | 115 if (!ctx->event.timer_set) { |
116 | 116 |
117 /* cleanup to remove the timer in case of abnormal termination */ | 117 /* cleanup to remove the timer in case of abnormal termination */ |
118 | 118 |
119 cln = ngx_http_cleanup_add(r, 0); | 119 cln = ngx_http_cleanup_add(r, 0); |
120 if (cln == NULL) { | 120 if (cln == NULL) { |
121 return NGX_ERROR; | 121 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
122 } | 122 } |
123 | 123 |
124 cln->handler = ngx_http_delay_body_cleanup; | 124 cln->handler = ngx_http_delay_body_cleanup; |
125 cln->data = ctx; | 125 cln->data = ctx; |
126 | 126 |