Click here to Skip to main content
15,887,821 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CreateThread Pin
Freak309-Oct-13 2:06
Freak309-Oct-13 2:06 
AnswerRe: CreateThread Pin
Richard Andrew x649-Oct-13 4:08
professionalRichard Andrew x649-Oct-13 4:08 
AnswerRe: CreateThread Pin
CPallini9-Oct-13 21:31
mveCPallini9-Oct-13 21:31 
QuestionHow to let the windows show top most? Pin
yu-jian8-Oct-13 4:24
yu-jian8-Oct-13 4:24 
SuggestionRe: How to let the windows show top most? Pin
Albert Holguin8-Oct-13 5:39
professionalAlbert Holguin8-Oct-13 5:39 
QuestionDigital signature in mail message created using MAPI Pin
Turosik7-Oct-13 4:17
Turosik7-Oct-13 4:17 
AnswerRe: Digital signature in mail message created using MAPI Pin
rashin ghodratzade7-Oct-13 5:36
rashin ghodratzade7-Oct-13 5:36 
Question[C/C++] Parse multipart/form-data POST request in a small web server Pin
csrss6-Oct-13 21:29
csrss6-Oct-13 21:29 
Hi there.
I am looking for a simple, basic, preferable a C way of parsing multipart/form-data POST request from a client browser. So far I have a really simple web server, which reads web browser requests in a loop and prints them to to command prompt window:
C++
do
{
    len = recv(..., input_buf, ...);

}
    while (!strstr(input_buf, "\r\n\r\n") && len > 0);

// Try to parse header and data
char * pch = nullptr, *context = nullptr;
pch = strtok_s(input_buf, "\r\n", &context);
while (pch != nullptr)
{
    ::puts(pch);
    pch = strtok_s (nullptr, "\r\n", &context);
}


When this web server starts, it just shows the following web form to the web browser:
HTML
<form type=multipart/form-data method=post action=submit><input type=file multiple required /><input type=submit /></form>


So far so good, ok, I connect to my server with firefox, select some test text file, which is a really small one - just a couple of bytes and hit an html form submit button. Server reads request and I have the following output in command prompt window:

POST /submit HTTP/1.1
Host: localhost:6666
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:24.0) Gecko/20100101 Firefox/
24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://localhost:6666/
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 0


But the question is, how do I get file data? I was reading tons of online docs, when it says something about boundary strings - I have no idea what are boundary strings. I am just trying to figure out how to grab raw bytes file data. I cannot use any 3rd party libraries. And what concerns me, is that Content-Length is zero - seems like file was not transferred at all Frown | :(
Can anyone help me with this?
Thanks in advance Smile | :)
011011010110000101100011011010000110100101101110
0110010101110011

AnswerRe: [C/C++] Parse multipart/form-data POST request in a small web server Pin
csrss7-Oct-13 23:15
csrss7-Oct-13 23:15 
QuestionGMP and Windows Pin
BobInNJ5-Oct-13 11:01
BobInNJ5-Oct-13 11:01 
AnswerRe: GMP and Windows Pin
pasztorpisti5-Oct-13 11:58
pasztorpisti5-Oct-13 11:58 
GeneralRe: GMP and Windows Pin
rashin ghodratzade7-Oct-13 6:05
rashin ghodratzade7-Oct-13 6:05 
QuestionFind URL Pin
john56324-Oct-13 19:41
john56324-Oct-13 19:41 
AnswerRe: Find URL Pin
Richard MacCutchan4-Oct-13 20:43
mveRichard MacCutchan4-Oct-13 20:43 
AnswerRe: Find URL Pin
jschell5-Oct-13 10:46
jschell5-Oct-13 10:46 
AnswerRe: Find URL Pin
Albert Holguin8-Oct-13 5:43
professionalAlbert Holguin8-Oct-13 5:43 
QuestionCapturing all Keyboard input using a DLL Pin
Don Guy4-Oct-13 10:11
Don Guy4-Oct-13 10:11 
AnswerRe: Capturing all Keyboard input using a DLL Pin
jeron14-Oct-13 10:31
jeron14-Oct-13 10:31 
AnswerRe: Capturing all Keyboard input using a DLL Pin
rashin ghodratzade7-Oct-13 6:22
rashin ghodratzade7-Oct-13 6:22 
AnswerRe: Capturing all Keyboard input using a DLL Pin
vijith.squadz9-Oct-13 1:30
professionalvijith.squadz9-Oct-13 1:30 
QuestionEncode audio from .wav to .aac Pin
CodingHell4-Oct-13 0:33
CodingHell4-Oct-13 0:33 
AnswerRe: Encode audio from .wav to .aac Pin
jeron14-Oct-13 5:19
jeron14-Oct-13 5:19 
GeneralRe: Encode audio from .wav to .aac Pin
CodingHell6-Oct-13 20:03
CodingHell6-Oct-13 20:03 
QuestionRe: Encode audio from .wav to .aac Pin
jeron17-Oct-13 3:57
jeron17-Oct-13 3:57 
QuestionWhere is PCMFORMAT defined? Pin
Vaclav_3-Oct-13 5:21
Vaclav_3-Oct-13 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.