Skip to content

Commit d576b9c

Browse files
committed
make output parameter optional
1 parent 77b578f commit d576b9c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed
-26 Bytes
Binary file not shown.

build/src/ngx_http_image_filter_module.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ ngx_http_image_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
330330
ngx_chain_t out;
331331
ngx_http_image_filter_ctx_t *ctx;
332332
ngx_http_image_filter_conf_t *conf;
333-
ngx_str_t ofmt;
333+
ngx_str_t ofmt = ngx_null_string;
334334

335335
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "image filter");
336336

@@ -371,8 +371,7 @@ ngx_http_image_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
371371
}
372372

373373
ct = &ngx_http_image_types[ctx->type - 1];
374-
375-
if (ngx_http_complex_value(r, conf->output, &ofmt) == NGX_OK) {
374+
if (conf->output != NULL && ngx_http_complex_value(r, conf->output, &ofmt) == NGX_OK) {
376375
if (ngx_strncmp(ofmt.data, "jpg", 3) == 0 || ngx_strncmp(ofmt.data, "jpeg", 4) == 0) {
377376
ct = &ngx_http_image_types[NGX_HTTP_IMAGE_JPEG - 1];
378377

@@ -594,7 +593,7 @@ ngx_http_image_process(ngx_http_request_t *r)
594593
ngx_int_t rc;
595594
ngx_http_image_filter_ctx_t *ctx;
596595
ngx_http_image_filter_conf_t *conf;
597-
ngx_str_t ofmt;
596+
ngx_str_t ofmt = ngx_null_string;
598597

599598
r->connection->buffered &= ~NGX_HTTP_IMAGE_BUFFERED;
600599

@@ -605,11 +604,12 @@ ngx_http_image_process(ngx_http_request_t *r)
605604
conf = ngx_http_get_module_loc_conf(r, ngx_http_image_filter_module);
606605

607606
/* always transform when convert */
608-
if (ngx_http_complex_value(r, conf->output, &ofmt) == NGX_OK) {
607+
if (conf->output != NULL && ngx_http_complex_value(r, conf->output, &ofmt) == NGX_OK) {
609608
if (ofmt.len > 2) {
610609
ctx->force = 1;
611610
}
612611
}
612+
613613

614614
if (conf->filter == NGX_HTTP_IMAGE_SIZE) {
615615
return ngx_http_image_json(r, rc == NGX_OK ? ctx : NULL);
@@ -1305,13 +1305,13 @@ ngx_http_image_out(ngx_http_request_t *r, ngx_uint_t type, gdImagePtr img,
13051305
u_char *out;
13061306
ngx_int_t q;
13071307
ngx_http_image_filter_conf_t *conf;
1308-
ngx_str_t ofmt;
1308+
ngx_str_t ofmt = ngx_null_string;
13091309

13101310
out = NULL;
13111311

13121312
conf = ngx_http_get_module_loc_conf(r, ngx_http_image_filter_module);
1313-
1314-
if (ngx_http_complex_value(r, conf->output, &ofmt) == NGX_OK) {
1313+
1314+
if (conf->output != NULL && ngx_http_complex_value(r, conf->output, &ofmt) == NGX_OK) {
13151315
if (ngx_strncmp(ofmt.data, "jpg", 3) == 0 || ngx_strncmp(ofmt.data, "jpeg", 4) == 0){
13161316
type = NGX_HTTP_IMAGE_JPEG;
13171317

0 commit comments

Comments
 (0)