@@ -8,6 +8,8 @@ static ngx_int_t ngx_http_redirectionio_header_read(ngx_http_request_t *r, ngx_t
8
8
9
9
static ngx_int_t ngx_http_redirectionio_header_content_type_read (ngx_http_request_t * r , struct REDIRECTIONIO_HeaderMap * * first );
10
10
11
+ static ngx_int_t ngx_http_redirectionio_header_content_type_write (ngx_http_request_t * r , ngx_table_elt_t * h );
12
+
11
13
static ngx_int_t ngx_http_redirectionio_buffer_read (ngx_buf_t * buffer , struct REDIRECTIONIO_Buffer * output );
12
14
13
15
ngx_int_t ngx_http_redirectionio_match_on_response_status_header_filter (ngx_http_request_t * r ) {
@@ -145,13 +147,6 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
145
147
continue ;
146
148
}
147
149
148
- // Handle specific headers
149
- if (ngx_strcasecmp ((u_char * )header_map -> name , (u_char * )"Content-Type" ) == 0 ) {
150
- header_map = header_map -> next ;
151
-
152
- continue ;
153
- }
154
-
155
150
h = ngx_list_push (& r -> headers_out .headers );
156
151
157
152
if (h == NULL ) {
@@ -176,6 +171,10 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
176
171
r -> headers_out .content_encoding = h ;
177
172
}
178
173
174
+ if (ngx_strcasecmp ((u_char * )header_map -> name , (u_char * )"Content-Type" ) == 0 ) {
175
+ ngx_http_redirectionio_header_content_type_write (r , h );
176
+ }
177
+
179
178
header_map = header_map -> next ;
180
179
}
181
180
@@ -457,6 +456,54 @@ static ngx_int_t ngx_http_redirectionio_header_content_type_read(ngx_http_reques
457
456
return NGX_OK ;
458
457
}
459
458
459
+ static ngx_int_t ngx_http_redirectionio_header_content_type_write (ngx_http_request_t * r , ngx_table_elt_t * h ) {
460
+ u_char * p , * last ;
461
+
462
+ r -> headers_out .content_type_len = h -> value .len ;
463
+ r -> headers_out .content_type = h -> value ;
464
+ r -> headers_out .content_type_lowcase = NULL ;
465
+
466
+ for (p = h -> value .data ; * p ; p ++ ) {
467
+
468
+ if (* p != ';' ) {
469
+ continue ;
470
+ }
471
+
472
+ last = p ;
473
+
474
+ while (* ++ p == ' ' ) { /* void */ }
475
+
476
+ if (* p == '\0' ) {
477
+ return NGX_OK ;
478
+ }
479
+
480
+ if (ngx_strncasecmp (p , (u_char * ) "charset=" , 8 ) != 0 ) {
481
+ continue ;
482
+ }
483
+
484
+ p += 8 ;
485
+
486
+ r -> headers_out .content_type_len = last - h -> value .data ;
487
+
488
+ if (* p == '"' ) {
489
+ p ++ ;
490
+ }
491
+
492
+ last = h -> value .data + h -> value .len ;
493
+
494
+ if (* (last - 1 ) == '"' ) {
495
+ last -- ;
496
+ }
497
+
498
+ r -> headers_out .charset .len = last - p ;
499
+ r -> headers_out .charset .data = p ;
500
+
501
+ return NGX_OK ;
502
+ }
503
+
504
+ return NGX_OK ;
505
+ }
506
+
460
507
static ngx_int_t ngx_http_redirectionio_buffer_read (ngx_buf_t * buffer , struct REDIRECTIONIO_Buffer * output ) {
461
508
#if (NGX_HAVE_SENDFILE64 )
462
509
off_t offset ;
0 commit comments