Apache module for processing FORM in C

I am implementing the Apache 2.0.x module in C to interact with the existing product that we have. I need to process FORM data, most likely using POST, but I also want to process GET.

Nick Kew Apache modules have a section on processing form data. It provides code examples for POST and GET that return apr_hash_t key + value pairs in the form. parse_form_from_POST combines the bucket brigade and aligns it to a buffer, and parse_form_from_GET can simply refer to the URL. Both procedures rely on the parse_form_from_string procedure to go through each delimited field and retrieve information in a hash table.

This will be fine, but it seems like it should be an easier way to do this than adding a couple of hundred lines of code to my module. Is there an existing module or routine in apache, apr or apr-util for extracting field names and related data from GET or POST FORM into a structure with which C code can more easily be accessed? I cannot find anything suitable, but it seems like a general need for which there must be a solution.

+4
source share
3 answers

I switched to G-WAN, which offers a transparent ANSI C scripting interface for GET and POST forms (and many other useful features like charts, GIF I / O, etc.).

A few AJAX examples are available on the GWAN page .

Hope this helps!

+1
source

Although on the surface this may seem like a common occurrence, cgi content handlers in C on apache are quite rare. Most people just use CGI, FastCGI, or a lot of infrastructures like mod_perl.

Most of the C apache modules I wrote are designed to modify the specific behavior of the web server for specific purposes that apply to each request.

If you can write your handler at all outside the apache module, I would advise you to continue this strategy.

0
source

I have not tried any solution yet since I found this SO question as a result of my own frustration with the example described in the Apache Modules. But here is what I have found so far. I will update this answer as I research more.

Fortunately, this problem has now been resolved in Apache 2.4 using ap_parse_form_data funciton.

I don’t know how much this works compared to your example, but here is a much more concise read_post function .

It is also possible that mod_form may matter.

0
source

Source: https://habr.com/ru/post/1276950/


All Articles