Skip to content

Commit 7c03e04

Browse files
committed
Fix nginx and apache proxy tests
1 parent d8690ff commit 7c03e04

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/ngx_http_redirectionio_module.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ static ngx_int_t ngx_http_redirectionio_create_ctx_handler(ngx_http_request_t *r
180180

181181
ngx_http_set_ctx(r, ctx, ngx_http_redirectionio_module);
182182

183+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio init context");
184+
183185
redirectionio_log_init_with_callback(ngx_http_redirectionio_log_callback, r->connection->log);
184186
}
185187

@@ -226,6 +228,8 @@ static ngx_int_t ngx_http_redirectionio_redirect_handler(ngx_http_request_t *r)
226228
return NGX_AGAIN;
227229
}
228230

231+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio acquire connection from pool");
232+
229233
status = ngx_reslist_acquire(conf->connection_pool, ngx_http_redirectionio_pool_available, r);
230234

231235
if (status == NGX_AGAIN) {
@@ -247,6 +251,7 @@ static ngx_int_t ngx_http_redirectionio_redirect_handler(ngx_http_request_t *r)
247251
// if api not called call it and return ngx_again to wait for response
248252
if (ctx->matched_action_status == API_NOT_CALLED) {
249253
ctx->matched_action_status = API_WAITING;
254+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio call match action");
250255
ngx_http_redirectionio_write_match_action_handler(ctx->resource->peer.connection->write);
251256

252257
return NGX_AGAIN;
@@ -261,6 +266,7 @@ static ngx_int_t ngx_http_redirectionio_redirect_handler(ngx_http_request_t *r)
261266
}
262267

263268
redirect_status_code = redirectionio_action_get_status_code(ctx->action, 0);
269+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio status code before backend call %d", redirect_status_code);
264270

265271
if (redirect_status_code == 0) {
266272
return NGX_DECLINED;
@@ -447,6 +453,8 @@ static void ngx_http_redirectionio_read_match_action_handler(ngx_event_t *rev, c
447453
return;
448454
}
449455

456+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio action received: %s", action_serialized);
457+
450458
ctx->action = (struct REDIRECTIONIO_Action *)redirectionio_action_json_deserialize((char *)action_serialized);
451459

452460
if (ctx->action != NULL) {

src/ngx_http_redirectionio_module_filter.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ ngx_int_t ngx_http_redirectionio_match_on_response_status_header_filter(ngx_http
3434
return ngx_http_redirectionio_headers_filter(r);
3535
}
3636

37+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio status code update %d (on response status code)", redirect_status_code);
38+
3739
r->headers_out.status = redirect_status_code;
40+
r->headers_out.status_line.len = 0;
3841

3942
return ngx_http_redirectionio_headers_filter(r);
4043
}
@@ -68,6 +71,8 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
6871
part = &r->headers_out.headers.part;
6972
h = part->elts;
7073

74+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio start header filter");
75+
7176
for (i = 0; /* void */ ; i++) {
7277
if (i >= part->nelts) {
7378
if (part->next == NULL) {
@@ -95,12 +100,17 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
95100
ngx_memcpy((char *)current_header->value, h[i].value.data, h[i].value.len);
96101
*((char *)current_header->value + h[i].value.len) = '\0';
97102

103+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio add filter to send \"%s: %s\"", current_header->name, current_header->value);
104+
98105
first_header = current_header;
99106
}
100107

108+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio filtering on response status code %d", r->headers_out.status);
101109
first_header = (struct REDIRECTIONIO_HeaderMap *)redirectionio_action_header_filter_filter(ctx->action, first_header, r->headers_out.status);
102110

103111
if (first_header == NULL) {
112+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio no filter to add");
113+
104114
return ngx_http_redirectionio_create_filter_body(r);
105115
}
106116

@@ -117,6 +127,8 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
117127
part = &r->headers_out.headers.part;
118128
h = part->elts;
119129

130+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio header filter clean");
131+
120132
for (i = 0; /* void */ ; i++) {
121133
if (i >= part->nelts) {
122134
if (part->next == NULL) {
@@ -162,9 +174,13 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
162174
h->value.data = ngx_pcalloc(r->pool, h->value.len);
163175
ngx_memcpy(h->value.data, first_header->value, h->value.len);
164176

177+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio add header to response \"%s: %s\"", first_header->name, first_header->value);
178+
165179
first_header = first_header->next;
166180
}
167181

182+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http redirectionio header filter done");
183+
168184
return ngx_http_redirectionio_create_filter_body(r);
169185
}
170186

0 commit comments

Comments
 (0)