1
1
2
2
/*
3
- * Copyright (C) agentzh
3
+ * Copyright (C) Yichun Zhang ( agentzh)
4
4
*/
5
5
6
6
9
9
#endif
10
10
#include "ddebug.h"
11
11
12
+
12
13
#include "ngx_http_rds_csv_filter_module.h"
13
14
#include "ngx_http_rds_csv_util.h"
14
15
#include "ngx_http_rds_csv_processor.h"
@@ -33,9 +34,9 @@ static char *ngx_http_rds_csv_merge_loc_conf(ngx_conf_t *cf, void *parent,
33
34
void * child );
34
35
static ngx_int_t ngx_http_rds_csv_filter_init (ngx_conf_t * cf );
35
36
static char * ngx_http_rds_csv_row_terminator (ngx_conf_t * cf ,
36
- ngx_command_t * cmd , void * conf );
37
+ ngx_command_t * cmd , void * conf );
37
38
static char * ngx_http_rds_csv_field_separator (ngx_conf_t * cf ,
38
- ngx_command_t * cmd , void * conf );
39
+ ngx_command_t * cmd , void * conf );
39
40
static char * ngx_http_rds_csv (ngx_conf_t * cf , ngx_command_t * cmd , void * conf );
40
41
static void * ngx_http_rds_csv_create_main_conf (ngx_conf_t * cf );
41
42
@@ -104,10 +105,10 @@ static ngx_http_module_t ngx_http_rds_csv_filter_module_ctx = {
104
105
ngx_http_rds_csv_filter_init , /* postconfiguration */
105
106
106
107
ngx_http_rds_csv_create_main_conf , /* create main configuration */
107
- NULL , /* init main configuration */
108
+ NULL , /* init main configuration */
108
109
109
- NULL , /* create server configuration */
110
- NULL , /* merge server configuration */
110
+ NULL , /* create server configuration */
111
+ NULL , /* merge server configuration */
111
112
112
113
ngx_http_rds_csv_create_loc_conf , /* create location configuration */
113
114
ngx_http_rds_csv_merge_loc_conf /* merge location configuration */
@@ -157,23 +158,23 @@ ngx_http_rds_csv_header_filter(ngx_http_request_t *r)
157
158
158
159
conf = ngx_http_get_module_loc_conf (r , ngx_http_rds_csv_filter_module );
159
160
160
- if ( ! conf -> enabled ) {
161
+ if (! conf -> enabled ) {
161
162
return ngx_http_rds_csv_next_header_filter (r );
162
163
}
163
164
164
165
if (ngx_http_rds_csv_test_content_type (r ) != NGX_OK ) {
165
166
return ngx_http_rds_csv_next_header_filter (r );
166
167
}
167
168
168
- if (conf -> content_type .len == sizeof (ngx_http_rds_csv_content_type ) - 1 &&
169
- ngx_strncmp (conf -> content_type .data , ngx_http_rds_csv_content_type ,
170
- sizeof (ngx_http_rds_csv_content_type ) - 1 ) == 0 )
169
+ if (conf -> content_type .len == sizeof (ngx_http_rds_csv_content_type ) - 1
170
+ && ngx_strncmp (conf -> content_type .data , ngx_http_rds_csv_content_type ,
171
+ sizeof (ngx_http_rds_csv_content_type ) - 1 ) == 0 )
171
172
{
172
173
/* MIME type is text/csv, we process Content-Type
173
174
* according to RFC 4180 */
174
175
175
- len = sizeof (ngx_http_rds_csv_content_type ) - 1 +
176
- sizeof ("; header=" ) - 1 ;
176
+ len = sizeof (ngx_http_rds_csv_content_type ) - 1
177
+ + sizeof ("; header=" ) - 1 ;
177
178
178
179
if (conf -> field_name_header ) {
179
180
len += sizeof ("presence" ) - 1 ;
@@ -203,9 +204,9 @@ ngx_http_rds_csv_header_filter(ngx_http_request_t *r)
203
204
204
205
if (p - r -> headers_out .content_type .data != (ssize_t ) len ) {
205
206
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
206
- "rds_csv: content type buffer error: %uz != %uz" ,
207
- (size_t ) (p - r -> headers_out .content_type .data ),
208
- len );
207
+ "rds_csv: content type buffer error: %uz != %uz" ,
208
+ (size_t ) (p - r -> headers_out .content_type .data ),
209
+ len );
209
210
210
211
return NGX_ERROR ;
211
212
}
@@ -306,8 +307,8 @@ ngx_http_rds_csv_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
306
307
break ;
307
308
default :
308
309
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 ,
309
- "rds_csv: invalid internal state: %d" ,
310
- ctx -> state );
310
+ "rds_csv: invalid internal state: %d" ,
311
+ ctx -> state );
311
312
312
313
rc = NGX_ERROR ;
313
314
@@ -319,7 +320,7 @@ ngx_http_rds_csv_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
319
320
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE ) {
320
321
ctx -> state = state_done ;
321
322
322
- if (! ctx -> header_sent ) {
323
+ if (!ctx -> header_sent ) {
323
324
ctx -> header_sent = 1 ;
324
325
325
326
if (rc == NGX_ERROR ) {
@@ -411,24 +412,24 @@ ngx_http_rds_csv_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
411
412
ngx_conf_merge_value (conf -> field_name_header , prev -> field_name_header , 1 );
412
413
413
414
ngx_conf_merge_uint_value (conf -> field_sep , prev -> field_sep ,
414
- (ngx_uint_t ) ',' );
415
+ (ngx_uint_t ) ',' );
415
416
416
417
ngx_conf_merge_str_value (conf -> row_term , prev -> row_term ,
417
- ngx_http_rds_csv_row_term );
418
+ ngx_http_rds_csv_row_term );
418
419
419
420
ngx_conf_merge_str_value (conf -> content_type , prev -> content_type ,
420
- ngx_http_rds_csv_content_type );
421
+ ngx_http_rds_csv_content_type );
421
422
422
423
ngx_conf_merge_size_value (conf -> buf_size , prev -> buf_size ,
423
- (size_t ) ngx_pagesize );
424
+ (size_t ) ngx_pagesize );
424
425
425
426
return NGX_CONF_OK ;
426
427
}
427
428
428
429
429
430
static char *
430
431
ngx_http_rds_csv_row_terminator (ngx_conf_t * cf , ngx_command_t * cmd ,
431
- void * conf )
432
+ void * conf )
432
433
{
433
434
ngx_http_rds_csv_loc_conf_t * rlcf = conf ;
434
435
ngx_str_t * value ;
@@ -446,8 +447,8 @@ ngx_http_rds_csv_row_terminator(ngx_conf_t *cf, ngx_command_t *cmd,
446
447
return "takes empty string value" ;
447
448
}
448
449
449
- if ((term -> len == 1 && term -> data [0 ] == '\n' ) ||
450
- (term -> len == 2 && term -> data [0 ] == '\r' && term -> data [1 ] == '\n' ))
450
+ if ((term -> len == 1 && term -> data [0 ] == '\n' )
451
+ || (term -> len == 2 && term -> data [0 ] == '\r' && term -> data [1 ] == '\n' ))
451
452
{
452
453
return ngx_conf_set_str_slot (cf , cmd , conf );
453
454
}
@@ -458,7 +459,7 @@ ngx_http_rds_csv_row_terminator(ngx_conf_t *cf, ngx_command_t *cmd,
458
459
459
460
static char *
460
461
ngx_http_rds_csv_field_separator (ngx_conf_t * cf , ngx_command_t * cmd ,
461
- void * conf )
462
+ void * conf )
462
463
{
463
464
ngx_http_rds_csv_loc_conf_t * rlcf = conf ;
464
465
ngx_str_t * value ;
0 commit comments