httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Devender Reddy" <mudhiganti...@gmail.com>
Subject Re: How to retrieve the posted variables using the apache module...
Date Tue, 13 Feb 2007 07:32:19 GMT
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 <joe@joe-lewis.com> 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.
> >
> > <form method="post" enctype="multipart/form-data"
> > action="http://www.example.com/hey/there">
> > <input type="text" name="uname" /><br>
> > <br>File : <input type="file" name="uploadfile" />
> > <input type="hidden" name="hide" value="hidden value" />
> > <input type="submit" value="submit" name="submit" />
> > </form>
> >
> > 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, "<H1>Header in Elements are : </H1>\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, "<H1>Header out Elements are : </H1>\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 <joe@joe-lewis.com> 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 <http://sharktooth.org/>
> >> "Divide the fire, and you will sooner put it out." - Publius Syrus
> >>
> >
> >
>
>
> --
> Joseph Lewis <http://sharktooth.org/>
> "Divide the fire, and you will sooner put it out." - Publius Syrus
>



-- 
Thanks & Regards
Dev

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message