Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

31337

Parsing CGI http Upload with C++

This topic is 5273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a CGI script in C++ and I'm having problems parsing the file upload data. Below is a dump of what the post data looks like . Excluding the uploaded file data, I can get everything.
-----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="RadioGroup1" 1 -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="Browse"; filename="test" Content-Type: application/octet-stream - -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="file" File Data Here -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="numRandomization" 1000 -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="logGenDist" 1 -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="logGeoDist" 1 -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="zeroTo" 0.000100 -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="negDistances" 1 -----------------------------180734101920433395901356561919 Content-Disposition: form-data; name="Submit" Submit -----------------------------180734101920433395901356561919--
Now, of course I can get everything EXCEPT the data found after name="Browse"; In the specific file I uploaded the file consisted of nothing more than a single - character (the filename is test). Also, before and after the - character are bytes valued at 13 in decimal. Now, I was thinking, why not just grab the data inbetween the 13's, but then it occurred to me that there might be 13's in the uploaded data. So how am I suppossed to determine the file size from that given data? For clarity, I've put another clip with a different test file being uploaded with something a little more clear - "Hello GameDev, this is my file!".
-----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="RadioGroup1" 1 -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="Browse"; filename="test" Content-Type: application/octet-stream Hello GameDev, this is my File! -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="file" File Data Here -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="numRandomization" 1000 -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="logGenDist" 1 -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="logGeoDist" 1 -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="zeroTo" 0.000100 -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="negDistances" 1 -----------------------------9621407641317308791765360437 Content-Disposition: form-data; name="Submit" Submit -----------------------------9621407641317308791765360437--
I'm also wondering about the meaning behind Content-Type: application/octet-stream. Will it always be application/octet-stream? I've tried uploading binary executables and it stays the same. So, any help would be appreciated (as always), thanks in advance. This is driving me insane. [edited by - 31337 on June 7, 2004 2:01:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
The contents of the file are MIME encoded and then uploaded. You probably need to decode it first. Try googling for MIME Decoding.

Share this post


Link to post
Share on other sites
Can anybody shed some light on this for me? I''ve looked up MIME decoding but I''m really confused

Share this post


Link to post
Share on other sites
I know this is hopelessly pragmatic for GameDev, but why can''t you use a Perl script and be done with it? You''re using a language that is horrible with text processing and potentially unsafe with the possibility of buffer overruns.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!