SimpleHttpServer icon indicating copy to clipboard operation
SimpleHttpServer copied to clipboard

handle multipart/form-data post uploads

Open oscarsan opened this issue 9 years ago • 3 comments

When trying for example send a text file using curl $ curl -F [email protected] http://localhost:8080

You can see that there is still header info in the actual data, this needs to be stripped of, somehow related to this.

oscarsan avatar Oct 14 '15 07:10 oscarsan

Correct... SimpleHttpServer does not currently handle multipart-post file upload, only application/x-www-form-urlencoded. It is a small educational server designed to learn the basics of HTTP.. Right now, the code should probably be checking the POST content type and throwing an exception on unhandled multipart/form-data uploads.

The link you posted does discuss multi-part form upload. Unfortunately, the example PopulatePostMultiPart won't handle binary data or large uploads, because it's decoding everything into a string. Here is a better description...

http://stackoverflow.com/questions/8659808/how-does-http-file-upload-work

jeske avatar Oct 14 '15 18:10 jeske

Good article, i was thinking would be wise to just encode the binary, like base64 and send it as string, That is handle in easier way by http and can be decode in the server side.

oscarsan avatar Oct 14 '15 19:10 oscarsan

It is not easier to base64 the data. All that is needed is to properly implement multi-part file upload on the server.

If it will help, i can spend some time implementing this. It is not hard.

jeske avatar Oct 14 '15 22:10 jeske