I need to send certain data to the server in a .zip archive, over HTTP POST request, MIME encoded. I take it that means only that I need to specify MIME type in a request header. But I'm confused as to what should I put in request's body. So far I can see two ways to do it:
Usually, as I take it (sorry, I'm not a web coder, so kinda lame with HTTP), POST request body consists of pairs parameter_name=some+data divided by '&'. Should I do it the same way and write contents of my file in base64 in one of parameters? That would also let me provide supplemental parameters.
Or should I just fill POST body with contents of my file (in base64, right?)? If so, is there any way to provide additional info about the file?
Is only one of theese ways acceptable or are both? If so, what would be the best practice?
Also, code sample in C++ for Qt would be very-very much appreciated, but totally not necessary :)
The whole key=value body in POST requests is just for when you are sending form-data to your server. If you want to POST only the contents of a .zip file you can just send that as the body of your POST, no need to set it up like a form post as you describe. You can set the following headers in the request:
You don't even necessarily have to base64 encode the body, although you should if that's what your server is expecting.
The Content-Disposition is the thing you need to describe more about your file upload. You can find some details about it here:
http://en.wikipedia.org/wiki/MIME#Content-Disposition
and here
http://www.ietf.org/rfc/rfc2183.txt
At the server end, you just need to write some code which will get the response body in its entirity (which is straightforward, although YMMV depending on language and framework), and handle it however you want.
For a real world example, you might find it useful to look at, say, AtomPub for how this is done:
http://bitworking.org/projects/atom/rfc5023.html