Forum: NGINX Modifying response body

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
57badfb3e8a4e8a81536f7dc6e47b812?d=identicon&s=25 Joe Van Dyk (Guest)
on 2009-05-06 18:05
(Received via mailing list)
2 questions:
Is it possible to return an empty response?  i.e.
  location /empty-response {
    add_header("some-header", "foo-bar");
    # nothing in response body
  }

Is it possible have the response body be only the unique id set by the
userid module?  i.e.
  userid on;
  location /unique-id {
    # response body should be "uid=<cookie's uid>"
  }

Thanks,
Joe
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2009-05-06 21:10
(Received via mailing list)
Hello!

On Wed, May 06, 2009 at 08:57:31AM -0700, Joe Van Dyk wrote:

> 2 questions:
> Is it possible to return an empty response?  i.e.
>   location /empty-response {
>     add_header("some-header", "foo-bar");
>     # nothing in response body
>   }

Something like

    location /empty-response {
        add_header ...;
        return 204;
    }

should work for http-complaint applications (but not some popular
browsers).

> Is it possible have the response body be only the unique id set by the
> userid module?  i.e.
>   userid on;
>   location /unique-id {
>     # response body should be "uid=<cookie's uid>"
>   }

Either use embedded perl or try http_response module by Kirill
Korinskiy
(http://catap.ru/downloads/nginx/ngx_http_response-0.3.tar.gz).

Maxim Dounin
57badfb3e8a4e8a81536f7dc6e47b812?d=identicon&s=25 Joe Van Dyk (Guest)
on 2009-05-06 21:57
(Received via mailing list)
On Wed, May 6, 2009 at 12:02 PM, Maxim Dounin <mdounin@mdounin.ru>
wrote:

>
> Something like
>
>    location /empty-response {
>        add_header ...;
>        return 204;
>    }
>
> should work for http-complaint applications (but not some popular
> browsers).


I earlier tried returning a 200 and it seemed to hang on me.  Maybe
browser
problem?


>  > Is it possible have the response body be only the unique id set by the
> > userid module?  i.e.
> >   userid on;
> >   location /unique-id {
> >     # response body should be "uid=<cookie's uid>"
> >   }
>
> Either use embedded perl or try http_response module by Kirill
> Korinskiy (http://catap.ru/downloads/nginx/ngx_http_response-0.3.tar.gz).


Thanks.  I think I will just proxy the request to a Sinatra app, even
though
I'm losing a lot of performance.  Is that module for nginx 0.6.x?
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2009-05-06 23:48
(Received via mailing list)
Hello!

On Wed, May 06, 2009 at 12:49:30PM -0700, Joe Van Dyk wrote:

> > >     # nothing in response body
> > browsers).
>
>
> I earlier tried returning a 200 and it seemed to hang on me.  Maybe browser
> problem?

No, returning 200 won't do anything good.  For now it will
basically instruct nginx to "forgot" about request without sending
anything (pretending reply was already sent).

Returning 204 should work as it returns correct HTTP reply with
empty content - but AFAIK at least IE have problems with it.

>
> Thanks.  I think I will just proxy the request to a Sinatra app, even though
> I'm losing a lot of performance.  Is that module for nginx 0.6.x?

It should work for both 0.6.* and 0.7.*.

Looks like it doesn't compile with 0.7.53+ due to trivial unused
function declaration warning though.  But it's really trivial to
fix even without C knowledge (just remove offending line or
./configure nginx with --with-cc-opt="-Wno-error").

Maxim Dounin
This topic is locked and can not be replied to.