Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added more debug level error log outputs to ease debugging (as discus…

…sed in github issue #2)
  • Loading branch information...
commit 23c47f226f9c992eee0248151d99fae05111c8f3 1 parent 2574878
@agentzh agentzh authored
View
28 src/ngx_http_rds_json_filter_module.c
@@ -4,7 +4,9 @@
*/
+#ifndef DDEBUG
#define DDEBUG 0
+#endif
#include "ddebug.h"
#include "ngx_http_rds_json_filter_module.h"
@@ -171,7 +173,8 @@ ngx_http_rds_json_header_filter(ngx_http_request_t *r)
{
ngx_http_set_ctx(r, NULL, ngx_http_rds_json_filter_module);
- dd("status is not OK: %d, skipping", (int) r->headers_out.status);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "rds json: skipped due to bad status: %ui", r->headers_out.status);
return ngx_http_rds_json_next_header_filter(r);
}
@@ -180,11 +183,18 @@ ngx_http_rds_json_header_filter(ngx_http_request_t *r)
conf = ngx_http_get_module_loc_conf(r, ngx_http_rds_json_filter_module);
- if ( ! conf->enabled) {
+ if (!conf->enabled) {
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "rds json: skipped because not enabled in the current location");
+
return ngx_http_rds_json_next_header_filter(r);
}
if (ngx_http_rds_json_test_content_type(r) != NGX_OK) {
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "rds json: skipped due to unmatched Content-Type response "
+ "header \"%V\"", &r->headers_out.content_type);
+
return ngx_http_rds_json_next_header_filter(r);
}
@@ -226,6 +236,9 @@ ngx_http_rds_json_header_filter(ngx_http_request_t *r)
r->filter_need_in_memory = 1;
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "rds json header filter postponed header sending");
+
/* we do postpone the header sending to the body filter */
return NGX_OK;
}
@@ -247,6 +260,9 @@ ngx_http_rds_json_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
return ngx_http_rds_json_next_body_filter(r, in);
}
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "rds json body filter postponed header sending");
+
switch (ctx->state) {
case state_expect_header:
rc = ngx_http_rds_json_process_header(r, in, ctx);
@@ -270,9 +286,10 @@ ngx_http_rds_json_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
case state_done:
- /* mark the remaining bufs as consumed */
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "rds json body filter discarding unexpected trailing buffers");
- dd("discarding bufs");
+ /* mark the remaining bufs as consumed */
ngx_http_rds_json_discard_bufs(r->pool, in);
@@ -302,7 +319,8 @@ ngx_http_rds_json_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
r->headers_out.status = rc;
- dd("sending ERROR headers");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "rds json body filter sending error page headers");
ngx_http_rds_json_next_header_filter(r);
ngx_http_send_special(r, NGX_HTTP_LAST);
View
2  src/ngx_http_rds_json_handler.c
@@ -1,4 +1,6 @@
+#ifndef DDEBUG
#define DDEBUG 0
+#endif
#include "ddebug.h"
#include "ngx_http_rds_json_handler.h"
View
2  src/ngx_http_rds_json_output.c
@@ -4,7 +4,9 @@
*/
+#ifndef DDEBUG
#define DDEBUG 0
+#endif
#include "ddebug.h"
#include "ngx_http_rds_json_filter_module.h"
View
2  src/ngx_http_rds_json_processor.c
@@ -3,7 +3,9 @@
*/
+#ifndef DDEBUG
#define DDEBUG 0
+#endif
#include "ddebug.h"
#include "ngx_http_rds_json_processor.h"
View
2  src/ngx_http_rds_json_util.c
@@ -1,4 +1,6 @@
+#ifndef DDEBUG
#define DDEBUG 0
+#endif
#include "ddebug.h"
#include "resty_dbd_stream.h"
View
22 t/sanity.t
@@ -6,9 +6,9 @@ use Test::Nginx::Socket;
#repeat_each(10);
no_shuffle();
-repeat_each(1);
+repeat_each(2);
-plan tests => repeat_each() * 2 * blocks() + 2 * repeat_each() * 3;
+plan tests => repeat_each() * (2 * blocks() + 7);
$ENV{TEST_NGINX_MYSQL_HOST} ||= '127.0.0.1';
$ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
@@ -439,3 +439,21 @@ GET /mysql
{"errcode":0,"errstr":"Rows matched: 1 Changed: 0 Warnings: 0"}
--- SKIP
+
+
+=== TEST 17: bad MIME type
+--- http_config eval: $::http_config
+--- config
+ location /mysql {
+ default_type "text/css";
+ echo hello;
+ rds_json on;
+ }
+--- request
+GET /mysql
+--- response_headers
+Content-Type: text/css
+--- response_body
+hello
+--- timeout: 15
+
Please sign in to comment.
Something went wrong with that request. Please try again.