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 <[EMAIL PROTECTED]> 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



--
Thanks & Regards
Dev

Reply via email to