Re: Cgi and c++
El mi=E9rcoles, 11 de marzo de 2015, 17:16:45 (UTC+1), Tomas Garijo escrib=
i=F3:
Hello,
I'm noob in c++. My problem is next. A linux system, is sending to my a=
pache server a xml stream by http post. I need capture by CGI this stream =
xml and parsec it, but i don't know how to do this. The major problem is ca=
pture the xml stream. I don't know if i need a GCI API or Socket API. Pleas=
e can you help me?
Regards.
Hello,
I don't know what happend with my code, but I can't receive xml data by htt=
p post.
This is my code
int main(int argc, char *argv[])
{
cout << "Content-type:text/html\r\n\r\n";
cout << "<html>\n";
cout << "<head>\n";
cout << "<title>CGI Envrionment Variables</title>\n";
cout << "</head>\n";
cout << "<body>\n";
//cout << "<p>" << *argv[1] << "</p>" << endl;
//cout << "argc = " << argc << endl;
//cout << "argc =0 " << argv[0] << endl;
char *inputlenstr;
char *tmp;
int inputlen;
int status;
cout << "Tmp= " << *tmp << endl;
inputlenstr = getenv("CONTENT_LENGTH");
inputlen = atoi(inputlenstr);
status = fread(tmp, 1, inputlen, stdin);
cout << "Status= " << status << endl;
cout << "Tmp= " << *tmp << endl;
cout << "</body>\n";
cout << "</html>\n";
}
and this is a python program that send xml file (sorry for use python)
import requests
url = 'http://192.168.3.32/cgi-bin/xmlengine'
data = open('.//file.xml', 'r').read()
r = requests.post(url, data=data)
print(r.text)
This is the result
<html>
<head>
<title>CGI Envrionment Variables</title>
</head>
<body>
argc = 1
argc =0 /var/www/.netbeans/remote/192.168.3.32/tgarijow7-Windows-x86_64/P=
/xmleng
ine/dist/Debug/GNU-Linux-x86/xmlengine
Tmp= |
Status= 0
Tmp= |
</body>
</html>
PD: I used a java program to send xml file by http post and I have had the =
same result.
Regards