I try to send a HTML form using POST method but my request fails (the response I receive is "Internal Server Error"). I wrote a HTML page to compare with the same request, and it works.
This is the code of the HTML page :
^
form method="POST"
action="http://path/to/my/page.cfm"
enctype="multipart/form-data"
input type="text" name="PurgeXML" /
input type="submit" value="Send It" /
/form
^
This is now the C++ code I wrote, and doesn't work :
^
const string field("PurgeXML");
const string mypage("http://path/to/my/page.cfm");
const string data("" "
try {
URI uri(mypage);
string path(uri.getPathAndQuery());
if (path.empty()) {
path = "/";
}
HTTPClientSession session(uri.getHost(), uri.getPort());
HTTPRequest req(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_0);
HTMLForm form(HTMLForm::ENCODING_MULTIPART);
form.set(field,data);
form.prepareSubmit(req);
session.sendRequest(req);
HTTPResponse res;
istream& rs = session.receiveResponse(res);
if(res.getStatus() != HTTPResponse::HTTP_OK) {
//failure
}
stringstream responseS;
responseS << rs.rdbuf();
string response(responseS.str());
cout << response;
}catch (Poco::Exception& e) {
//failure
}
^
Can anybody help me to understand what is wrong ? (I'm a newbie in HTTP requests, and this is an important work).
Thanks in advance,
cd.





