Skip to content

Commit

Permalink
massive coding style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
agentzh committed Aug 3, 2013
1 parent b21333e commit 00ee3cf
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 120 deletions.
16 changes: 9 additions & 7 deletions src/ngx_http_headers_more_filter_module.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* Copyright (C) agentzh */
/*
* Copyright (C) Yichun Zhang (agentzh)
* */


#ifndef DDEBUG
#define DDEBUG 0
Expand Down Expand Up @@ -114,7 +117,7 @@ ngx_http_headers_more_filter(ngx_http_request_t *r)
ngx_http_headers_more_cmd_t *cmd;

ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"headers more header filter, uri \"%V\"", &r->uri);
"headers more header filter, uri \"%V\"", &r->uri);

conf = ngx_http_get_module_loc_conf(r, ngx_http_headers_more_filter_module);

Expand Down Expand Up @@ -242,10 +245,10 @@ ngx_http_headers_more_handler(ngx_http_request_t *r)
ngx_http_headers_more_cmd_t *cmd;

ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"headers more rewrite handler, uri \"%V\"", &r->uri);
"headers more rewrite handler, uri \"%V\"", &r->uri);

hmcf = ngx_http_get_module_main_conf(r,
ngx_http_headers_more_filter_module);
ngx_http_headers_more_filter_module);

if (! hmcf->postponed_to_phase_end) {
ngx_http_core_main_conf_t *cmcf;
Expand All @@ -265,10 +268,10 @@ ngx_http_headers_more_handler(ngx_http_request_t *r)
if (cur_ph < last_ph) {
dd("swaping the contents of cur_ph and last_ph...");

tmp = *cur_ph;
tmp = *cur_ph;

memmove(cur_ph, cur_ph + 1,
(last_ph - cur_ph) * sizeof (ngx_http_phase_handler_t));
(last_ph - cur_ph) * sizeof (ngx_http_phase_handler_t));

*last_ph = tmp;

Expand Down Expand Up @@ -326,4 +329,3 @@ ngx_http_headers_more_pre_config(ngx_conf_t *cf)
ngx_http_headers_more_filter_used = 0;
return NGX_OK;
}

39 changes: 20 additions & 19 deletions src/ngx_http_headers_more_headers_in.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* Copyright (C) agentzh */
/*
* Copyright (C) Yichun Zhang (agentzh)
* */


#ifndef DDEBUG
#define DDEBUG 0
Expand All @@ -14,7 +17,7 @@
static char * ngx_http_headers_more_parse_directive(ngx_conf_t *cf,
ngx_command_t *ngx_cmd, void *conf,
ngx_http_headers_more_opcode_t opcode);
static ngx_flag_t ngx_http_headers_more_check_type(ngx_http_request_t *r,
static int ngx_http_headers_more_check_type(ngx_http_request_t *r,
ngx_array_t *types);
static ngx_int_t ngx_http_set_header(ngx_http_request_t *r,
ngx_http_headers_more_header_val_t *hv, ngx_str_t *value);
Expand Down Expand Up @@ -130,10 +133,8 @@ ngx_http_headers_more_exec_input_cmd(ngx_http_request_t *r,
return NGX_OK;
}

if (cmd->types) {
if ( ! ngx_http_headers_more_check_type(r, cmd->types) ) {
return NGX_OK;
}
if (cmd->types && !ngx_http_headers_more_check_type(r, cmd->types)) {
return NGX_OK;
}

h = cmd->headers->elts;
Expand Down Expand Up @@ -195,15 +196,14 @@ ngx_http_set_header_helper(ngx_http_request_t *r,
}

if (h[i].key.len == hv->key.len
&& ngx_strncasecmp(h[i].key.data,
hv->key.data,
h[i].key.len) == 0)
&& ngx_strncasecmp(h[i].key.data, hv->key.data,
h[i].key.len) == 0)
{
if (value->len == 0) {
h[i].hash = 0;

rc = ngx_http_headers_more_rm_header_helper(
&r->headers_in.headers, part, i);
&r->headers_in.headers, part, i);

if (rc == NGX_OK) {
if (output_header) {
Expand Down Expand Up @@ -322,7 +322,7 @@ ngx_http_set_host_header(ngx_http_request_t *r,

static ngx_int_t
ngx_http_set_content_length_header(ngx_http_request_t *r,
ngx_http_headers_more_header_val_t *hv, ngx_str_t *value)
ngx_http_headers_more_header_val_t *hv, ngx_str_t *value)
{
off_t len;

Expand Down Expand Up @@ -367,7 +367,7 @@ ngx_http_headers_more_set_input_headers(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf)
{
return ngx_http_headers_more_parse_directive(cf, cmd, conf,
ngx_http_headers_more_opcode_set);
ngx_http_headers_more_opcode_set);
}


Expand All @@ -376,10 +376,11 @@ ngx_http_headers_more_clear_input_headers(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf)
{
return ngx_http_headers_more_parse_directive(cf, cmd, conf,
ngx_http_headers_more_opcode_clear);
ngx_http_headers_more_opcode_clear);
}

static ngx_flag_t

static int
ngx_http_headers_more_check_type(ngx_http_request_t *r, ngx_array_t *types)
{
ngx_uint_t i;
Expand All @@ -396,8 +397,8 @@ ngx_http_headers_more_check_type(ngx_http_request_t *r, ngx_array_t *types)
}

dd("headers_in->content_type: %.*s",
(int) actual_type.len,
actual_type.data);
(int) actual_type.len,
actual_type.data);

t = types->elts;
for (i = 0; i < types->nelts; i++) {
Expand All @@ -416,7 +417,7 @@ ngx_http_headers_more_check_type(ngx_http_request_t *r, ngx_array_t *types)

static char *
ngx_http_headers_more_parse_directive(ngx_conf_t *cf, ngx_command_t *ngx_cmd,
void *conf, ngx_http_headers_more_opcode_t opcode)
void *conf, ngx_http_headers_more_opcode_t opcode)
{
ngx_http_headers_more_loc_conf_t *hcf = conf;

Expand Down Expand Up @@ -523,8 +524,8 @@ ngx_http_headers_more_parse_directive(ngx_conf_t *cf, ngx_command_t *ngx_cmd,
}

dd("Found %d types, and %d headers",
(int) cmd->types->nelts,
(int) cmd->headers->nelts);
(int) cmd->types->nelts,
(int) cmd->headers->nelts);

if (cmd->headers->nelts == 0) {
ngx_pfree(cf->pool, cmd->headers);
Expand Down
Loading

0 comments on commit 00ee3cf

Please sign in to comment.