i am just trying to connect to google with inet functions with a small console app and for some reason its printing 9 chars to console only and not the whole html page , thanks if you can help
Code:
#include "stdafx.h"
#include <windows.h>
#include <Wininet.h>
#include <stdio.h>
#pragma comment(lib,"Wininet.lib")
int main
{
char NetBuffer[4000],NetBufferToWrite[5000],NetBuildToWrite[5000];
DWORD NetRead,NetToRead;
DWORD NetWrite,NetToWrite;
HINTERNET Net = InternetOpen("Broswer:",
INTERNET_OPEN_TYPE_DIRECT,//INTERNET_OPEN_TYPE_PROXY, //INTERNET_OPEN_TYPE_DIRECT
NULL,//"socks=66.57.195.229:38671",
NULL,
NULL);//INTERNET_FLAG_ASYNC);
if(Net == NULL)
{
printf("%s\n","Something Went Wrong With Proxy Configuration");
printf("%d\n",GetLastError());
Sleep(5000);
}
else
{
//printf("%s\n","Proxy Connection Set!");
HINTERNET NetOpen = InternetOpenUrl(Net,
"http://google.co.uk", //
NULL,
NULL,
INTERNET_FLAG_KEEP_CONNECTION,
INTERNET_NO_CALLBACK);
if(NetOpen == NULL)
{
printf("%s\n","Failed to Connect To Url");
printf("%d\n",GetLastError()); //returns 997
}
else
{
printf("%s\n","Connected to Url");
Sleep(5000);
Sleep(5000);
//char *GetMain = "GET / HTTP/1.1\r\n"
LPCSTR Accept("text/*");
HINTERNET NetRequest = HttpOpenRequest(NetOpen,
"GET", //verbname GET/POST
NULL, //objectname
NULL, //http version 1.1
NULL, //refefer
&Accept, //type to accept
INTERNET_FLAG_RELOAD | INTERNET_FLAG_KEEP_CONNECTION,
NULL);
HttpSendRequest(NetRequest,
NULL,
NULL,
NULL,
NULL);
InternetReadFile(NetOpen,NetBuffer,NetRead,&NetToRead);
printf("%s %d\n","Number of Byte To Read",NetRead);
printf("%s %d\n",NetBuffer,strlen(NetBuffer));
}
}
Sleep(5000);
return 0;
}