I have a demand to implement a simple FileUploader app on top of
mozilla/necko. My initial goal is to have something like
% ./myUploader <server> <local_file>
basically just like TestUpload does
(http://lxr.mozilla.org/seamonkey/source/netwerk/test/TestUpload.cpp).
Maybe some changes on TestUpload example could be enough to get what I
want. On my local webserver, I have some simple html/php file uploader
running and I tried to make TestUpload to work with it. Doing:
% ./myUploader <my_server/uploader.php> <path_to_any_local_file>
I can reach the server, but I got a HTTP BAD REQUEST from apache.
After chatting to <biesi> on irc, he told me that before uploading
over http I would have to manually mime-encode my data, just like form
submission does
(http://lxr.mozilla.org/seamonkey/source/content/html/content/src/nsFormSubmission.cpp#1197),
but I am not sure how could I manually do this mime-encode from
TestUpload code, once it seems that there is no API for that. How
could that be possible ?
An MDC article titled "Creating Sandboxed HTTP Connections"
(http://developer.mozilla.org/en/docs/Creating_Sandboxed_HTTP_Connections)
teaches something similar, but it enctype with
"application/x-www-form-urlencoded" but as far as I understood, in my
specific case, data has to be mime-enconded with
"multipart/form-data".
Maybe it could be done like libcurl does
(http://curl.haxx.se/libcurl/c/libcurl-tutorial.html , ctrl+f "HTTP
POSTing") , which abstracts a html <form> behaviour.
Any clues ?
--
--Antonio Gomes