cgi post - clear data from stdin

O

Oliver Bleckmann

hey guys,
i have a little problem. my cgi routines are working so far,
but i need to redirect to the cgi-programm and what the
"posted" data to be cleared if redirected. i don't know
how the post method exactly works. maybe i have to
clear the stdin (tried fflush)!? maybe the is another reason
that the former data is displayed. fist i thought of the browser
cach, but it's the same problem using ctrl+f5.
i need to check if the cgi program is called with form data
or not, because checking the request method does not work either.
any ideas?

code:

.....
std::string meth_s = null_to_empty(std::getenv("REQUEST_METHOD"));
if (meth_s == "")
{
cout << "EMPTY" << endl;
// code in case no data is passed, doesn't work, because
of the persistent post data and
// it seems, that every url call ist a "get" command !?
}
else if (meth_s == "GET")
{
query = null_to_empty(getenv("QUERY_STRING"));
cout << "GET" << endl;
cout << query << endl;
} else if (meth_s == "POST")
{
// This is the routine for the query string, which
should be parsed and cleared on every program call, but remains even on a
ctrl+f5 refresh
int len = atoi(getenv("CONTENT_LENGTH"));
input = new char[len+1];
fread(input, 1, len, stdin);
input[len] = 0;
cout << "POST" << endl;
query = input;
cout << query << endl;
delete input;
//fflush ( stdin );
} else cout << "NONE" << endl;
.......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top