Search code examples
c++visual-studioweblogic

Sending Request using HTTPS in C++


My C++ application consists of posting out through an HTTP connection directly to the Weblogic App server. Need to change it to post using HTTPS.

*Im running this application through Visual Studio. *

Any kind of suggestions are welcome. Coding updates are most helpful

The below is the code i have for HTTP connectivity works fine.

What i need to do it to work with HTTPS?

      strFormData = sFile;

strHeaders  = _T("Content-Type: application/x-www-form-urlencoded");

CInternetSession session;
CHttpConnection* pConnection =  session.GetHttpConnection(_T(Server), Port);

CHttpFile* pFile =  pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,   _T(Action));                

result = pFile->SendRequest(strHeaders,(LPVOID)(LPCTSTR)strFormData,  
                                          Data.GetLength());

Solution

  • CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, _T(Action), NULL, 1, NULL, NULL, INTERNET_FLAG_SECURE);
    

    I tried this code and it worked out for HTTPS posting. I found that parametric values (Internet secure flag) varies with HTTP & HTTPS posting.