New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle gziped capture? #12

Closed
robert-martens opened this Issue Jan 17, 2011 · 3 comments

Comments

Projects
None yet
3 participants
@robert-martens

robert-martens commented Jan 17, 2011

This may be more of a question than an issue. I want to feed the body of one capture into another ex:
local res2 = ngx.location.capture("/cap2?"..res1.body)
However res1.body was gziped by the origin server. Any idea how I can prevent the gzip of the body (a special Accept-Encoding header maybe) or unzip it using something like the gzio library on luaforge (http://luaforge.net/projects/gzio/)?

@chaoslawful

This comment has been minimized.

Show comment
Hide comment
@chaoslawful

chaoslawful Jan 17, 2011

Contributor

Remove Accept-Encoding header from the request can prevent server responsing with gzip compressed content. If this can't be done, you can also decompress gzip'd content in Lua by using birmworks' lua-zlib module or similar ones (https://github.com/brimworks/lua-zlib).

Contributor

chaoslawful commented Jan 17, 2011

Remove Accept-Encoding header from the request can prevent server responsing with gzip compressed content. If this can't be done, you can also decompress gzip'd content in Lua by using birmworks' lua-zlib module or similar ones (https://github.com/brimworks/lua-zlib).

@agentzh

This comment has been minimized.

Show comment
Hide comment
@agentzh

agentzh Jan 17, 2011

Member

If you're using the ngx_proxy module for your subrequests, try using the following directive to prevent forwarding your original request's headers:

proxy_pass_request_headers off;

See http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass_request_headers for more details.

Alternatively, you can explicitly remove the Accep-Encoding header in your subrequest location like this:

 more_clear_input_headers Accept-Encoding;

You need the ngx_headers_more module though. See http://wiki.nginx.org/NginxHttpHeadersMoreModule#more_clear_input_headers for more details :)

Member

agentzh commented Jan 17, 2011

If you're using the ngx_proxy module for your subrequests, try using the following directive to prevent forwarding your original request's headers:

proxy_pass_request_headers off;

See http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass_request_headers for more details.

Alternatively, you can explicitly remove the Accep-Encoding header in your subrequest location like this:

 more_clear_input_headers Accept-Encoding;

You need the ngx_headers_more module though. See http://wiki.nginx.org/NginxHttpHeadersMoreModule#more_clear_input_headers for more details :)

@robert-martens

This comment has been minimized.

Show comment
Hide comment
@robert-martens

robert-martens Jan 18, 2011

Thank-you. All three options work.

OPTION ONE

Placed:
more_clear_input_headers Accept-Encoding;
in "location /cap2"

OPTION TWO

Placed:
proxy_pass_request_headers off;
in "location /cap2"

OPTION THREE

Downloaded https://github.com/brimworks/lua-zlib :
make linux
cp zlib.so /usr/lib/lua/5.1/zlib.so

added following to conf:
local zlib = require("zlib")
local stream = zlib.inflate()
local inflated_body = stream(res1.body)
local res2 = ngx.location.capture("/cap2?"..inflated_body)

I like having all three as options (may need gz some time and good to be able to modify the headers). I also like the work that both of you are doing; very cool.

robert-martens commented Jan 18, 2011

Thank-you. All three options work.

OPTION ONE

Placed:
more_clear_input_headers Accept-Encoding;
in "location /cap2"

OPTION TWO

Placed:
proxy_pass_request_headers off;
in "location /cap2"

OPTION THREE

Downloaded https://github.com/brimworks/lua-zlib :
make linux
cp zlib.so /usr/lib/lua/5.1/zlib.so

added following to conf:
local zlib = require("zlib")
local stream = zlib.inflate()
local inflated_body = stream(res1.body)
local res2 = ngx.location.capture("/cap2?"..inflated_body)

I like having all three as options (may need gz some time and good to be able to modify the headers). I also like the work that both of you are doing; very cool.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment