You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Danesh Daroui <da...@gmail.com> on 2018/09/19 12:57:53 UTC

Write a module to overwrite HTTP methods handling

Hi all,

I am sorry if my question is a bit off! I am wondering whether it is
possible to write a server module that can handle different HTTP
methods in a customized way? I mean, if I want to perform some action
when GET with some specific parameters comes in and/or PUT, POST or
DELETE as well, can I add handlers (which would preferably overwrite
the original handler) or I have to hack into the server code where
HTTP methods are handled? I have actually found where these methods
are handled (in default_handler inside protocol.c) but I am not sure
whether this is the best way to do so or not since rebasing to the
master would be be problematic when my local branch diverges as time
goes by.

At the same time, I believe that modules are to add extra features
e.g. authentication methods, compression techniques, encryption,
server management, etc, and not altering basic functionality of the
server or maybe it is possible since SSL is also implemented in a
module?

I would appreciate if you guide me through this.

Regards,

Danesh Daroui

Re: Write a module to overwrite HTTP methods handling

Posted by Danesh Daroui <da...@gmail.com>.
Hi Nick,

Thank you for your answer. I guess module for CGI would be a guideline
for what I need to do. I just want to double check whether I am on the
right track or not. So when a HTTP request with a query string is
received, in my mind, the only way to handle it is the CGI which would
in turn run an executable file with given parameters in the query
string that has been parsed by the server. I am wondering if all HTTP
methods, such as GET/DELETE/PUT/POST, etc. are handled in CGI or this
is only GET? Also, would I be able to use CGI module and tailor it for
my usage to handle a received request as I wish e.g. establishing a
connection to a database or do something else based on the query
string?

Thanks for your help,

Danesh Daroui

On Wed, Sep 19, 2018 at 4:51 PM Nick Kew <ni...@apache.org> wrote:
>
>
> > On 19 Sep 2018, at 13:57, Danesh Daroui <da...@gmail.com> wrote:
> >
> > Hi all,
> >
> > I am sorry if my question is a bit off! I am wondering whether it is
> > possible to write a server module that can handle different HTTP
> > methods in a customized way?
>
> Of course it's possible, and indeed common: see for example mod_dav,
> or even the oldest application module of all, mod_cgi.
>
> However, your question leads me to wonder if what you're looking for
> might not be better accomplished in configuration.  If you need
> functionality that isn't already supported, that would call for a new
> module (or equivalent), but you'd use configuration to determine
> when it should or shouldn't be invoked to process a request.
>
> --
> Nick Kew

Re: Write a module to overwrite HTTP methods handling

Posted by Nick Kew <ni...@apache.org>.
> On 19 Sep 2018, at 13:57, Danesh Daroui <da...@gmail.com> wrote:
> 
> Hi all,
> 
> I am sorry if my question is a bit off! I am wondering whether it is
> possible to write a server module that can handle different HTTP
> methods in a customized way?

Of course it's possible, and indeed common: see for example mod_dav,
or even the oldest application module of all, mod_cgi.

However, your question leads me to wonder if what you're looking for
might not be better accomplished in configuration.  If you need
functionality that isn't already supported, that would call for a new
module (or equivalent), but you'd use configuration to determine
when it should or shouldn't be invoked to process a request.

-- 
Nick Kew