Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 30383 invoked from network); 13 Feb 2007 07:32:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Feb 2007 07:32:45 -0000 Received: (qmail 33303 invoked by uid 500); 13 Feb 2007 07:32:52 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 33293 invoked by uid 500); 13 Feb 2007 07:32:51 -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 33284 invoked by uid 99); 13 Feb 2007 07:32:51 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Feb 2007 23:32:51 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of mudhiganti123@gmail.com designates 64.233.182.188 as permitted sender) Received: from [64.233.182.188] (HELO nf-out-0910.google.com) (64.233.182.188) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Feb 2007 23:32:41 -0800 Received: by nf-out-0910.google.com with SMTP id n28so153797nfc for ; Mon, 12 Feb 2007 23:32:19 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=RjNlDDyRzNNS3EjZ/bEoMu1LlpFjqg63ZsM66WJOlsfcu2KuJTJ1Mo4aG3Aej0+PycH3RQH9wNs4S+WD73qucT6nS4XbIh90cUXAzwGMLKMMtml4ECApmyPLFSADa/w07KKGmSckWK3kffgTdRbE2URnBVKJz0amaCnx86uu0fE= Received: by 10.82.152.16 with SMTP id z16mr11256441bud.1171351939168; Mon, 12 Feb 2007 23:32:19 -0800 (PST) Received: by 10.82.185.8 with HTTP; Mon, 12 Feb 2007 23:32:19 -0800 (PST) Message-ID: Date: Tue, 13 Feb 2007 13:02:19 +0530 From: "Devender Reddy" To: "Joe Lewis" Subject: Re: How to retrieve the posted variables using the apache module... Cc: modules-dev@httpd.apache.org In-Reply-To: <45D083C3.6060407@joe-lewis.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_103036_12986343.1171351939065" References: <45CC8CE2.9030309@joe-lewis.com> <45D083C3.6060407@joe-lewis.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_103036_12986343.1171351939065 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 > -- Thanks & Regards Dev ------=_Part_103036_12986343.1171351939065--