Get body of HTTP request in LUA

Hi,

is there a simple way to access the body of a HTTP request in IncomingHttpRequestFilter LUA function ?

The function parameters only provides method and uri (and httpHeaders in coming Orthanc 1.0.1) which is fine for GET and DELETE requests, but I would like to filter POST and PUT requests based on their body content.

How can I do this ?
Thanks.

Marc

Hello,

To be fair, I do not understand your use case.

The “IncomingHttpRequestFilter” is present to know whether a REST request should be authorized or forbidden by the HTTP server (i.e. it implements ACL - Access control lists). The body of the request should not be taken into consideration at this point.

To handle the body of the request in more evolved ways, you can create a C/C++ plugin using “OrthancPluginRegisterRestCallback()”.

HTH,
Sébastien-

Hi Sebastien,

there can be many different reasons to reject an incoming REST request. The identity of user or ACL permissions are common reasons, but on might want to detect missing or invalid body content. Request could then be filtered at reception to avoid passing it to internal or plugin resource and generating exceptions or malfunctions because of malformed body.

To be honest, I’m not a C++ developer, and LUA is a very simple, useful and flexible language to quickly code and test real-time functionalities without having to compile a plugin every time you make a change.

Regards,
Marc

Hello,

Thanks for the explanation, but I am not keen on breaking the abstraction of ACL for a body-filtering task that could be implemented elsewhere as a C/C++ plugin.

If someone else finds an interest in this feature, I could consider including it, but I do not have enough arguments to implement it right now.

Sorry,
Sébastien-