Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CHttpConnection OpenRequest SendRequest [modified]

CHttpConnection OpenRequest SendRequest [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpcombeta-testinghelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dehseth
    wrote on last edited by
    #1

    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 WRITE HTTP:// at the beginning of URL! I guess msdn should contain such an info! :cool:

    modified on Saturday, September 6, 2008 11:08 AM

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups