The following code
fRequestHandle = HttpOpenRequestA(
fConnectHandle,
\"POST\", url.c_str(),
NULL,
In general, your url should be 2k or less in size. Since you are performing a POST, you are heading in the right direction, its just that for the bulk of your data, you want to pass that as the body of the HTTP request like in this example:
POST /login.jsp HTTP/1.1
Host: www.mysite.com
User-Agent: Mozilla/4.0
Content-Length: 27
Content-Type: application/x-www-form-urlencoded
userid=joe&password=guessme <--You need to do this!
Cribbed from here: http://developers.sun.com/mobility/midp/ttips/HTTPPost/
Here's what I was thinking you would want to do:
std::string url("http://host.com/url");
std::string dataPayload("name=value&othername=anothervalue");//Query string payload style.
DWORD dataPayloadLength = dataPayload.length();
std::ostringstream headerStream;
headerStream << "content-length: ";
headerStream << dataPayloadLength;
std::string headers = headerStream.str();
DWORD headerLength = headers.length();
HINTERNET handle = HttpOpenRequest(hConnect,
"POST",
url.c_str(),
NULL, NULL, NULL,
INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE,
0);
if(!handle) {
DWORD errorCode = GetLastError();
//Handle error here.
}
//Use this thing to send POST values.
if(! HttpSendRequest(handle,
headers.c_str(),
headerLength,
dataPayload, //lpOptional <--Your POST data...not really optional for you.
dataPayloadLength) {
DWORD errorCode = GetLastError();
//Handle error here.
}