Unable to make a successfull CHttpFile.SendRequest() call
-
I keep getting an error 500 returned (I do analyze the return value in the actual code - this is simplified). It does not throw an exception - I am reaching the server and if I download the returned page - I get the server-generated error HTML. Here is my code:
void SomeClass::SomeFunction() { CInternetSession session("TheAgent"); CHttpConnection* server = NULL; CHttpFile* page; CString headers; CString& refheaders=headers; DWORD dwRet; DWORD& refdwRet = dwRet; try { server = session.GetHttpConnection("somewhere.com", (INTERNET_PORT)80); page = server->OpenRequest(CHttpConnection::HTTP_VERB_GET, "http://somewhere.com/index.htm"); headers = "Accept: text/*\r\nUser-Agent: TheAgent\r\n"; page->AddRequestHeaders(refheaders); // ERROR CODE IS ALWAYS 500 page->SendRequest(); page->QueryInfoStatusCode(refdwRet); // ERROR CODE IS ALWAYS 500 if (dwRet == HTTP_STATUS_OK) MessageBox("SUCCESS"); else MessageBox("ERROR"); delete page; delete server; } catch (CInternetException* pEx) { MessageBox("CATCH"); } session.Close(); } // exit function
My server is running fine. I can take the same URL in the OpenRequest() call and paste it into the browser and the page loads just fine.
-
I keep getting an error 500 returned (I do analyze the return value in the actual code - this is simplified). It does not throw an exception - I am reaching the server and if I download the returned page - I get the server-generated error HTML. Here is my code:
void SomeClass::SomeFunction() { CInternetSession session("TheAgent"); CHttpConnection* server = NULL; CHttpFile* page; CString headers; CString& refheaders=headers; DWORD dwRet; DWORD& refdwRet = dwRet; try { server = session.GetHttpConnection("somewhere.com", (INTERNET_PORT)80); page = server->OpenRequest(CHttpConnection::HTTP_VERB_GET, "http://somewhere.com/index.htm"); headers = "Accept: text/*\r\nUser-Agent: TheAgent\r\n"; page->AddRequestHeaders(refheaders); // ERROR CODE IS ALWAYS 500 page->SendRequest(); page->QueryInfoStatusCode(refdwRet); // ERROR CODE IS ALWAYS 500 if (dwRet == HTTP_STATUS_OK) MessageBox("SUCCESS"); else MessageBox("ERROR"); delete page; delete server; } catch (CInternetException* pEx) { MessageBox("CATCH"); } session.Close(); } // exit function
My server is running fine. I can take the same URL in the OpenRequest() call and paste it into the browser and the page loads just fine.
Terry O`Nolley wrote: page = server->OpenRequest(CHttpConnection::HTTP_VERB_GET, "http://somewhere.com/index.htm");
OpenRequest
should take the resourse name not the whole pathpage = server->OpenRequest(CHttpConnection::HTTP_VERB_GET, "index.htm")
-
Terry O`Nolley wrote: page = server->OpenRequest(CHttpConnection::HTTP_VERB_GET, "http://somewhere.com/index.htm");
OpenRequest
should take the resourse name not the whole pathpage = server->OpenRequest(CHttpConnection::HTTP_VERB_GET, "index.htm")
THANK YOU!!!!!!!!!!!!! (5)