Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 46385 invoked from network); 13 Feb 2007 08:22:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Feb 2007 08:22:46 -0000 Received: (qmail 78968 invoked by uid 500); 13 Feb 2007 08:22:54 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 78757 invoked by uid 500); 13 Feb 2007 08:22:53 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 78748 invoked by uid 99); 13 Feb 2007 08:22:53 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Feb 2007 00:22:53 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [199.203.54.245] (HELO vl654.host245.netvision.net.il) (199.203.54.245) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Feb 2007 00:22:42 -0800 Received: from [192.168.210.245] (89-138-186-238.bb.netvision.net.il [89.138.186.238]) (authenticated bits=0) by mail1.mirimar.net (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l1D8MFw0027888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 13 Feb 2007 10:22:17 +0200 Message-ID: <45D17535.1030509@beamartyr.net> Date: Tue, 13 Feb 2007 10:22:13 +0200 From: Issac Goldstand Organization: Mirimar Networks User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: How to retrieve the posted variables using the apache module... References: <45CC8CE2.9030309@joe-lewis.com> <45D083C3.6060407@joe-lewis.com> In-Reply-To: X-Enigmail-Version: 0.93.0.0 OpenPGP: url=http://www.beamartyr.net/pubkey.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Devender, Look at apreq (http://httpd.apache.org/apreq/) This module is designed to do exactly what you want, and will work with both Apache 1.3 and Apache 2.x Issac Devender Reddy wrote: > Thanks for the information. Right now I'm working on Apache 1.3 version. > Kindly let me know whether filters are supported for this version. If > supported, it would be great if you can share me some links to those. > > What I'm trying to do is.... > > Basically, I want to filter the data (POST data + File contents from > upload) > > - send the file contents to different server (server1) > - get the response back from the server > - then add the response (from server1) to the already existing POST > data > - then send that to some other server (server2). > > > If filters are not supported, then kindly let me know how to go about this > scenario. > > Thanks & Regards, > Dev. > > On 2/12/07, Joe Lewis wrote: >> >> Dev; >> >> You really want an filter, not a handler. By the time you get to a >> handler, the input "POST" information has been read. As suggested, use >> the apreq API's to grab it in a handler, or if you have to modify or >> catch it before any other modules, put it into an input filter. >> >> Joe >> >> Devender Reddy wrote: >> > Hi Joe, >> > >> > Thanks for your reply. Actually, I dumped all the data that is >> > there in request_rec->header_in datastructure, but still I couldn't >> > find the Posted variables in that datastructure. >> > >> > FYI, Here I am putting the HTML file, where the user enters his name >> > and will upload one file. >> > >> >
> > action="http://www.example.com/hey/there"> >> >
>> >
File : >> > >> > >> >
>> > >> > and Here I had written a module, to retrieve the name, upload file >> > name and hidden values. >> > >> > int iterate_func(void *req, const char *key, const char *value) >> > { >> > int stat; >> > char *line; >> > request_rec *r = (request_rec *)req; >> > if (key == NULL || value == NULL || value[0] == '\0') >> > return 1; >> > >> > line = ap_psprintf(r->pool, "%s => %s\n", key, value); >> > stat = ap_rputs(line, r); >> > >> > return 1; >> > } >> > >> > >> > static int hello_handler (request_rec * r) >> > { >> > ....... >> > >> > ap_send_http_header (r); >> > ap_table_do(iterate_func, r, r->headers_in, NULL); >> > >> > /* This is the another way of trying to get the header_in contents. */ >> > >> > table *in = r->headers_in; >> > array_header *arr = ap_table_elts (in); >> > >> > char **list = (char **) arr->elts; >> > int i; >> > >> > ap_rprintf (r, "

Header in Elements are :

\n"); >> > for (i = 0; i < arr->nelts; i++) >> > { >> > ap_rprintf (r, "item %d -> %s; \n", i, list[i]); >> > } >> > >> > table *out = r->headers_out; >> > arr = ap_table_elts(out); >> > >> > list = (char **) arr->elts; >> > >> > ap_rprintf (r, "

Header out Elements are :

\n"); >> > for (i = 0; i < arr->nelts; i++) >> > { >> > ap_rprintf (r, "item %d -> %s; \n", i, list[i]); >> > } >> > >> > return OK; >> > } >> > >> > /* Make the name of the content handler known to Apache */ >> > static handler_rec hello_handlers[] = { >> > {"hello-handler", hello_handler}, >> > {NULL} >> > }; >> > >> > /* Tell Apache what phases of the transaction we handle */ >> > module MODULE_VAR_EXPORT hello_module = { >> > STANDARD_MODULE_STUFF, >> > NULL, /* module initializer */ >> > NULL, /* per-directory config creator */ >> > NULL, /* dir config merger */ >> > NULL, /* server config creator */ >> > NULL, /* server config merger */ >> > NULL, /* command table */ >> > hello_handlers, /* [9] content handlers */ >> > NULL, /* [2] URI-to-filename translation */ >> > NULL, /* [5] check/validate user_id */ >> > NULL, /* [6] check user_id is valid *here* */ >> > NULL, /* [4] check access by host address */ >> > NULL, /* [7] MIME type checker/setter */ >> > NULL, /* [8] fixups */ >> > NULL, /* [10] logger */ >> > NULL, /* [3] header parser */ >> > NULL, /* process initialization */ >> > NULL, /* process exit/cleanup */ >> > NULL /* [1] post read_request handling */ >> > }; >> > >> > >> > So please let me know, if I did anything wrong. >> > Thanks in advance for doing this favour. >> > >> > Dev >> > >> > On 2/9/07, Joe Lewis wrote: >> >> Devender Reddy wrote: >> >> > Hi, >> >> > >> >> > I am writing an apache module in C and I am facing some problem >> while >> >> > retreiveing the POST elements data. >> >> [snip] >> >> > >> >> > Now I have to write one apache module in C, such that, I can get the >> >> > data of name, upload file name and the hidden variable. >> >> Are you sure you need a module and not a perl or php script? If you >> >> NEED an extension for apache, read on. >> >> > >> >> > I am assuming that these values are stored in the request_rec >> >> > structure. I dumped all the elements in this structure, but I >> couldn't >> >> > find the information. So it would be great, if you can help in this. >> >> Incoming HTTP headers are stored in the request_rec->headers_in >> >> apr_table. You can write a filter that grabs POST data before any >> other >> >> module gets it if you needed to alter the data. If you don't need to >> >> alter the data, you probably don't want an apache extension, just a >> >> standard CGI program. >> >> > >> >> > I know this is a pretty simple question, but this one seems to be a >> >> > tough for me as I am new to this area. >> >> We'll help as far as we are allowed to by list etiquette. >> >> >> >> Joe >> >> -- >> >> Joseph Lewis >> >> "Divide the fire, and you will sooner put it out." - Publius Syrus >> >> >> > >> > >> >> >> -- >> Joseph Lewis >> "Divide the fire, and you will sooner put it out." - Publius Syrus >> > > >