Question about request_body and redirect

Hi all:

I try to implemente a module based on NGINX, which will filter the
content
of request body.
Now, I met a problem: I can not get the whole request body

my code is as following:

len = rb->buf->last - rb->buf->pos ;
post_content = ngx_palloc(r->pool, len + 1);
ngx_cpystrn(post_body, rb->buf->pos, len);

it seems that if the body size is over 256 Bytes, we can not get the
right
request body length.

my questions are:

  1. how can I get the correct length of request body ?
  2. Do I need copy the request body to a buffur and then filter? Does
    serverar buff hold the data and link the buff-chain ?

Other issue:
I want to redirect some unsafe URLs to different safe URL, like
http://www.abc.com/a.index redirect to http://www.1234.com/a.index
http://www.abc.com/b.index rediect to http://www.5566.com/b.index

I use the function: ngx_http_internal_redirect() to implementate, but
I
always get a crash.
Any idea about these ?

thanks
NextHop.

quan nexthop at 2009-8-19 17:33 wrote:

Other issue:
I want to redirect some unsafe URLs to different safe URL, like
http://www.abc.com/a.index redirect to http://www.1234.com/a.index
http://www.abc.com/b.index rediect to http://www.5566.com/b.index

I use the function: ngx_http_internal_redirect() to implementate,
but I always get a crash.
Any idea about these ?

ngx_http_internal_redirect() can just redirect the request in the same
host.

You can return the request with 301 or use the Nginx’s proxy_pass
directive.

Weibin:
thank a lots
NextHop.

Hi,

On Wed, Aug 19, 2009 at 5:33 PM, quan nexthop[email protected]
wrote:

ngx_cpystrn(post_body, rb->buf->pos, len);

it seems that if the body size is over 256 Bytes, we can not get the right
request body length.

my questions are:

  1. how can I get the correct length of request body ?
  2. Do I need copy the request body to a buffur and then filter? Does
    serverar buff hold the data and link the buff-chain ?

You should use ‘r->request_body->bufs’. And keep in mind that there
might be one or two buffers in the chain.

Cheers!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs