Welcome! Log In Create A New Profile

Advanced

Sub-request using Parent Request Body

Roman Vasilyev
January 03, 2011 10:00PM
Hello,

I'm trying to make POST analyzer module. To have ability with SPAM
detection for passing throw traffic, for this I need to have
request_body in subrequest, for that I took agentzh / nginx-eval-module

http://forum.nginx.org/read.php?2,84026,84605

and after reading this posts made small changes (please find it below)
on small tests it working fine, but on something with big POSTs it
loosing information, could somebody help me with understanding how
better fix this.

--- ngx_http_eval_module.c 2010-12-19 19:55:08.000000000 -0800
+++ ngx_http_eval_module.c.new 2011-01-03 11:39:36.000000000 -0800
@@ -155,6 +155,11 @@
NGX_MODULE_V1_PADDING
};

+void
+ngx_http_stub(ngx_http_request_t *r)
+{
+}
+
static ngx_int_t
ngx_http_eval_handler(ngx_http_request_t *r)
{
@@ -261,7 +266,23 @@
return rc;
}

- sr->discard_body = 1;
+ rc = ngx_http_read_client_request_body(r, ngx_http_stub);
+
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
+ return rc;
+ }
+
+ ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
+ "eval: request_body \"%p\"", r->request_body);
+ if (r->request_body) {
+ sr->request_body = ngx_palloc(r->pool,
sizeof(ngx_http_request_body_t));
+ if (sr->request_body == NULL) {
+ return NGX_ERROR;
+ }
+ ngx_memcpy(sr->request_body, r->request_body,
sizeof(ngx_http_request_body_t));
+ } else {
+ sr->discard_body = 1;
+ }

ctx->in_progress = 1;



_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Sub-request using Parent Request Body

Roman Vasilyev January 03, 2011 10:00PM

Re: Sub-request using Parent Request Body

agentzh January 03, 2011 10:22PM

Re: Sub-request using Parent Request Body

Roman Vasilyev January 03, 2011 10:54PM

Re: Sub-request using Parent Request Body

agentzh January 04, 2011 01:28AM

Re: Sub-request using Parent Request Body

Roman Vasilyev January 04, 2011 07:24PM

Re: Sub-request using Parent Request Body

agentzh January 06, 2011 12:06AM

Re: Sub-request using Parent Request Body

agentzh January 06, 2011 12:08AM

Re: Sub-request using Parent Request Body

agentzh January 06, 2011 12:16AM

Re: Sub-request using Parent Request Body

Roman Vasilyev January 06, 2011 07:38PM

Re: Sub-request using Parent Request Body

Adrian Janeczek January 06, 2011 07:38PM

Re: Sub-request using Parent Request Body

agentzh January 07, 2011 01:40AM

Re: Sub-request using Parent Request Body

Roman Vasilyev January 07, 2011 03:18PM

Re: Sub-request using Parent Request Body

agentzh January 08, 2011 02:26AM

Re: Sub-request using Parent Request Body

Roman Vasilyev January 10, 2011 02:42PM

Re: Sub-request using Parent Request Body

Roman Vasilyev January 10, 2011 03:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 203
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready