Mailing List Archive

Lua r:requestbody() removes HTTP request body
Hi,

I trying to read every HTTP request message body (Apache httpd
2.4.5/Debian 9.5) where content type is equal to 'text/xml'. For this
purpose I use a Lua handler script during the request translation phase
using the directive 'LuaHookTranslateName'
(https://publib.boulder.ibm.com/httpserv/manual24/mod/mod_lua.html#luahooktranslatename).

This Lua handler script uses the function 'r:requestbody()' defined in
the reference manual section 'Built in function'
(https://publib.boulder.ibm.com/httpserv/manual24/mod/mod_lua.html#functions).
This method reads and returns the body of the HTTP request but it also
REMOVES the body of the request.

Is this bug reported?

Does exist any other request body reading function alternative?

I couldn't find any alternative in the 'lua_module' reference
documentation.

Thanks,

Bruno.

--
bruno.mendoza@ikeasi.com
live:.cid.fcefe3e243ddd719
010000100110100101110100011000100110111101111000


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Lua r:requestbody() removes HTTP request body [ In reply to ]
On Tue, Nov 29, 2022 at 10:45 AM bruno.mendoza <bruno.mendoza@ikeasi.com> wrote:
>
>
> Hi,
>
> I trying to read every HTTP request message body (Apache httpd
> 2.4.5/Debian 9.5) where content type is equal to 'text/xml'. For this
> purpose I use a Lua handler script during the request translation phase
> using the directive 'LuaHookTranslateName'
> (https://publib.boulder.ibm.com/httpserv/manual24/mod/mod_lua.html#luahooktranslatename).
>
> This Lua handler script uses the function 'r:requestbody()' defined in
> the reference manual section 'Built in function'
> (https://publib.boulder.ibm.com/httpserv/manual24/mod/mod_lua.html#functions).
> This method reads and returns the body of the HTTP request but it also
> REMOVES the body of the request.
>
> Is this bug reported?

Give https://httpd.apache.org/docs/current/mod/mod_request.html a try,
it is a way to opt-in to buffering the request body so it can be read
multiple times.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Lua r:requestbody() removes HTTP request body [ In reply to ]
El 2022-11-29 15:56, Eric Covener escribió:
> On Tue, Nov 29, 2022 at 10:45 AM bruno.mendoza
> <bruno.mendoza@ikeasi.com> wrote:
>>
>>
>> Hi,
>>
>> I trying to read every HTTP request message body (Apache httpd
>> 2.4.5/Debian 9.5) where content type is equal to 'text/xml'. For this
>> purpose I use a Lua handler script during the request translation
>> phase
>> using the directive 'LuaHookTranslateName'
>> (https://publib.boulder.ibm.com/httpserv/manual24/mod/mod_lua.html#luahooktranslatename).
>>
>> This Lua handler script uses the function 'r:requestbody()' defined in
>> the reference manual section 'Built in function'
>> (https://publib.boulder.ibm.com/httpserv/manual24/mod/mod_lua.html#functions).
>> This method reads and returns the body of the HTTP request but it also
>> REMOVES the body of the request.
>>
>> Is this bug reported?
>
> Give https://httpd.apache.org/docs/current/mod/mod_request.html a try,
> it is a way to opt-in to buffering the request body so it can be read
> multiple times.


Hi Eric,

I tried:

""
<VirtualHost *:80>

[...]

<LocationMatch "^/<affected_url_segment>">
KeptBodySize 10240
</LocationMatch>

LuaHookTranslateName "/some/location/script.lua" handle

[...]

</VirtualHost>
""

But the result is the same. After calling mod_lua 'r:requestbody()'
function the request body is removed.

I'm "proxying" HTTP requests to another HTTP service.

Does exist another way of using "mod_request"?

Thanks for your answers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org