I'm writing my first CGI program, and it's in C. Right now, I'm just output all the environment variables and their values.
My question relates to the method="post" action="multipart/form-data" combination, and the boundary separators.
As seen in the attached image, the boundary indicator starts with 4 hyphens and end with an "M".
In the lower part of the image, (you can't see so good) I'm breaking up the attached file (a ruby script) at newline characters, and substituting a "<br />" in it's place so it will display properly.
However, it appears the boundary markers differ slightly. In the CONTENT_TYPE, when read from STDIN, the markers start with 6 hyphens.
And in the smaller image, you can see that the last boundary marker even has 2 trailing hyphens.
When I read the content, here is my loop:
clength is a straight atoi() of CONTENT_LENGTH, which leads me to think I'm reading the right amount of data.Code:for ( i = 0 ; i < clength ; ++i ) { char c = fgetc(stdin) ; if (c=='\n') printf("<br />") ; else printf( "%c", c ) ; }
Any ideas?
Thanks, Todd