Create a Request from a String

Hi,

I’m trying to store requests that comes in (let’s call it request A),
and I
want to be able to “replay” them later, when another query comes in with
a
specific argument (request B).
I can store the request to memcache, and get it back later. But I can’t
figure out how to recreate a query from a string.

The only way I can think about would be to use an upstream module with
the
create_request method, but I would like to avoid duplicating most of the
proxy module,
and I don’t necessarily want to send the saved query to an upstream.

So while processing request B, I get the saved request A as a string. Is
there at that point a way to create a request from that string like if
it
was going through ngx_http_process_request_line() ?

Thank you,

Matthieu.

Hi,

I’m trying to store requests that comes in (let’s call it request A), and
I
want to be able to “replay” them later, when another query comes in with a
specific argument (request B).
I can store the request to memcache, and get it back later. But I can’t
figure out how to recreate a query from a string.

You can do this with both: ngx_echo [1] and ngx_lua [2].

You should also read agentzh’s post on that matter [3],
it will answer pretty much all of your questions :wink:

[1] http://wiki.nginx.org/NginxHttpEchoModule
[2] GitHub - openresty/lua-nginx-module: Embed the Power of Lua into NGINX HTTP servers
[3] A simple ngx_lua example for the future | Human & Machine

Best regards,
Piotr S. < [email protected] >

On Tue, May 25, 2010 at 1:19 AM, Piotr S.
[email protected]wrote:

You can do this with both: ngx_echo [1] and ngx_lua [2].

You should also read agentzh’s post on that matter [3],
it will answer pretty much all of your questions :wink:

[1] http://wiki.nginx.org/NginxHttpEchoModule
[2] GitHub - openresty/lua-nginx-module: Embed the Power of Lua into NGINX HTTP servers
[3] A simple ngx_lua example for the future | Human & Machine

Thanks for the pointers, but it doesn’t really answer my question.
Agentzh’s post shows how to send the content fetched from memcached to
the
downstream.

I’m trying to send that content representing a request, to an upstream.
Basically “replaying” a query stored as a string, exactly as if it was
coming from an open socket.

Thank you,

Matthieu.

On Wed, May 26, 2010 at 2:14 AM, Matthieu T.
[email protected] wrote:

Thanks for the pointers, but it doesn’t really answer my question.
Agentzh’s post shows how to send the content fetched from memcached to the
downstream.

Aye :slight_smile:

I’m trying to send that content representing a request, to an upstream.
Basically “replaying” a query stored as a string, exactly as if it was
coming from an open socket.

Basically it’s boiled down to manipulating r->headers_in and
r->request_body in a rewrite or access phase handler and then forward
to request object to the upstream handler (remember upstream is a
content handler pe se?) :slight_smile:

ngx_headers_more has the code for the former while ngx_chunkin and
ngx_echo do have some examples for the latter :slight_smile:

Cheers,
-agentzh