Skip to content

Instantly share code, notes, and snippets.

Created April 8, 2013 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d0ace002ff84156870ab to your computer and use it in GitHub Desktop.
Save anonymous/d0ace002ff84156870ab to your computer and use it in GitHub Desktop.
void __stdcall send_data(Connection conn){
ostringstream ossPostData;
string sPostData;
string sUserAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0";
HINTERNET hSession, hInternet, hConn, hReq;
string req_domain, req_path;
req_domain = "192.168.1.2";
req_path = "/";
hSession = InternetOpen(sUserAgent.c_str(), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
hInternet = InternetConnect(hSession, req_domain.c_str(), 80, 0, 0, INTERNET_SERVICE_HTTP, 0, 0);
hReq = HttpOpenRequest(hInternet, "POST", req_path.c_str(), 0, 0, 0, INTERNET_FLAG_RELOAD, 0);
if(conn.method == "GET"){
ossPostData << conn.method << " " << conn.url;
} else {
ossPostData << conn.method << " " << conn.url << endl << conn.post;
}
sPostData = string(ossPostData.str());
HttpSendRequest(hReq, NULL, 0, (PVOID)sPostData.c_str(), sPostData.size());
InternetCloseHandle(hSession);
InternetCloseHandle(hConn);
InternetCloseHandle(hReq);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment