CHttpConnection OpenRequest SendRequest [modified]
-
Hi everybody, I have been having problems with http post using visual c++ (not .Net) Here is my code:
CInternetSession session("My Session");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
DWORD dwRet;
char szBuff[1024];try { CString strServerName = "http://www.cnn.com"; INTERNET\_PORT nPort = 80; pServer = session.GetHttpConnection(strServerName, nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP\_VERB\_GET, ""); //strObject); //pFile->AddRequestHeaders(NULL); // szHeaders); pFile->SendRequest(); pFile->QueryInfoStatusCode(dwRet); if (dwRet == HTTP\_STATUS\_OK) { ...
Well I have tried a lot of code combinations. And when I realized application crashes at
pFile->SendRequest();
I decided to make a GET instead of POST. Well it still does not work. When I run the code above I got a MessageBox saying The URL is invalid :doh: And when I run with AddRequestHeaders(NULL) line it basicly crashes.. I have done a research at web but cannot find anything useful. My main purpose is to open a URL which I can do it using session::openurl and after getting the content post a form and get feedback from post. Thank you all --- OK People the problem is solved. Guess what I SHALL NOT WRITEHTTP://
at the beginning of URL! I guess msdn should contain such an info! :cool:modified on Saturday, September 6, 2008 11:08 AM