How to retrieve https webpage using visual c++

Dear pro,

For example:

how do I retrieve above webpage directly, and through a proxy server?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

use AfxParseURL for parse url and use AFX_INET_SERVICE_HTTPS
like this

if page take Get request;

void GetMyPage()
DWORD   dwAccessType = INTERNET_OPEN_TYPE_DIRECT;  // We are connecting to internet directly
DWORD dwServiceType;
CInternetSession session(("IP"),0, dwAccessType);
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
CString strServerName ;
CString strObject;

AfxParseURL("", dwServiceType, strServerName, strObject, nPort) ||      dwServiceType != AFX_INET_SERVICE_HTTPS)
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,strObject, NULL, 1, NULL, NULL, INTERNET_FLAG_SECURE);

pFile->SendRequest ();

//then you can write the data in a file

fp=fopen(tempfilename,"w");   //open the file to write the page content in a temp file
if(fp != NULL)
while(retval = (pFile->Read(buf,sizeof(buf))))

please also declare

int retval = 0;                        // Number of bytes read from the internet
char buf[1024];                        // Read the page content in buffer
FILE * fp = NULL;                  // To write the page content in a file

and also close


if (pFile != NULL)
    delete pFile;
if (pServer != NULL)
   delete pServer;

after pFile->Close();

tempfilename is file name in which you want to write reading data

Now same for PROXY only change is

>> DWORD   dwAccessType = INTERNET_OPEN_TYPE_DIRECT;  // We are connecting to internet directly

now you use
>> CInternetSession session(("IP"),0, dwAccessType);

you use

session=new CInternetSession(("IP"),0, dwAccessType ,strProxyServer);

//strProxyServer is use for proxy ip

and all other things are same

i think this solve your problem
but if your request is not GET type or it is POST type then tell i also tell that also



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.