You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jain Sachinkumar <sa...@umbc.edu> on 2010/01/20 19:07:02 UTC

[users@httpd] Handling multipart/form-data requests via Apache Module

Hello,

We are interested in logging HTTP requests that are sent to web
applications hosted on the Apache web server. Eventually, as part of a
larger research project, we would like to be able to replay these requests
automatically on the web application. For this purpose, we have developed
an Apache module which logs HTTP GET and POST requests and associated data
in a seperate file. In this module, I am able to log data that is
associated with a POST request, but I am having difficulty handling
multipart/form-data requests and was hoping I could get some help from the
community on this.

Consider for example, the following form

upload.html
<form enctype="multipart/form-data" action="uploader.php" method="POST">
Last Name:  <input type="text" name="lname" size="20" /><br />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

uploader.php
This is the php script which will handles the file that is sent through
the HTML page.

In our logger, we already have the functionality to log the 'lname',
'uploadedfile' fields and their values. But, in addition to the file's
name which comes as a value of the 'uplaodedfile' form field, we would
like to get the file's contents as well. We would like to save the file to
a predetermined location, for e.g., if the user uploads a zip file, we
would like the logger to store the zip file before passing it on to the
web application.

Is there a way to get the file contents in a logger software that is
sitting on Apache between the user and the web application. Any
suggestions/advice would be appreciated.

Regards,
- Sachin Jain
Research Assistant,
Information Systems Department,
University of Maryland, Baltimore County



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Handling multipart/form-data requests via Apache Module

Posted by Jain Sachinkumar <sa...@umbc.edu>.
Hello Devraj,

Thanks for the quick response.

I am using C to write my module.

Can you give me some guideline to decode the mime string? If the contents
of multipart data is just text file, it is easy to read it and write to
other file, but in case of zipped file or image file, how this is to be
handled?

Language is not a problem, If there is better way to do this in Perl or
Python, I can do that also.

Regards,
- Sachin Jain

> If you can access the POST data then it should be a matter of decoding
> the mime string and get the multipart data out.
>
> Are you writing your module in C, Perl or Python?
>
> On Thu, Jan 21, 2010 at 5:07 AM, Jain Sachinkumar <sa...@umbc.edu>
> wrote:
>> Hello,
>>
>> We are interested in logging HTTP requests that are sent to web
>> applications hosted on the Apache web server. Eventually, as part of a
>> larger research project, we would like to be able to replay these
>> requests
>> automatically on the web application. For this purpose, we have
>> developed
>> an Apache module which logs HTTP GET and POST requests and associated
>> data
>> in a seperate file. In this module, I am able to log data that is
>> associated with a POST request, but I am having difficulty handling
>> multipart/form-data requests and was hoping I could get some help from
>> the
>> community on this.
>>
>> Consider for example, the following form
>>
>> upload.html
>> <form enctype="multipart/form-data" action="uploader.php" method="POST">
>> Last Name:  <input type="text" name="lname" size="20" /><br />
>> Choose a file to upload: <input name="uploadedfile" type="file" /><br />
>> <input type="submit" value="Upload File" />
>> </form>
>>
>> uploader.php
>> This is the php script which will handles the file that is sent through
>> the HTML page.
>>
>> In our logger, we already have the functionality to log the 'lname',
>> 'uploadedfile' fields and their values. But, in addition to the file's
>> name which comes as a value of the 'uplaodedfile' form field, we would
>> like to get the file's contents as well. We would like to save the file
>> to
>> a predetermined location, for e.g., if the user uploads a zip file, we
>> would like the logger to store the zip file before passing it on to the
>> web application.
>>
>> Is there a way to get the file contents in a logger software that is
>> sitting on Apache between the user and the web application. Any
>> suggestions/advice would be appreciated.
>>
>> Regards,
>> - Sachin Jain
>> Research Assistant,
>> Information Systems Department,
>> University of Maryland, Baltimore County
>>
>>
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server
>> Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>
>
>
> --
> Follow me on Twitter, http://twitter.com/mdevraj
>
> "The secret impresses no-one, the trick you use it for is everything"
> - Alfred Borden (The Prestiege)
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
>




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Handling multipart/form-data requests via Apache Module

Posted by Devraj Mukherjee <de...@gmail.com>.
If you can access the POST data then it should be a matter of decoding
the mime string and get the multipart data out.

Are you writing your module in C, Perl or Python?

On Thu, Jan 21, 2010 at 5:07 AM, Jain Sachinkumar <sa...@umbc.edu> wrote:
> Hello,
>
> We are interested in logging HTTP requests that are sent to web
> applications hosted on the Apache web server. Eventually, as part of a
> larger research project, we would like to be able to replay these requests
> automatically on the web application. For this purpose, we have developed
> an Apache module which logs HTTP GET and POST requests and associated data
> in a seperate file. In this module, I am able to log data that is
> associated with a POST request, but I am having difficulty handling
> multipart/form-data requests and was hoping I could get some help from the
> community on this.
>
> Consider for example, the following form
>
> upload.html
> <form enctype="multipart/form-data" action="uploader.php" method="POST">
> Last Name:  <input type="text" name="lname" size="20" /><br />
> Choose a file to upload: <input name="uploadedfile" type="file" /><br />
> <input type="submit" value="Upload File" />
> </form>
>
> uploader.php
> This is the php script which will handles the file that is sent through
> the HTML page.
>
> In our logger, we already have the functionality to log the 'lname',
> 'uploadedfile' fields and their values. But, in addition to the file's
> name which comes as a value of the 'uplaodedfile' form field, we would
> like to get the file's contents as well. We would like to save the file to
> a predetermined location, for e.g., if the user uploads a zip file, we
> would like the logger to store the zip file before passing it on to the
> web application.
>
> Is there a way to get the file contents in a logger software that is
> sitting on Apache between the user and the web application. Any
> suggestions/advice would be appreciated.
>
> Regards,
> - Sachin Jain
> Research Assistant,
> Information Systems Department,
> University of Maryland, Baltimore County
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



-- 
Follow me on Twitter, http://twitter.com/mdevraj

"The secret impresses no-one, the trick you use it for is everything"
- Alfred Borden (The Prestiege)

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org