コード例 #1
0
ファイル: HttpObj.cpp プロジェクト: killvxk/WebbrowserLock
BOOL CAmHttpSocket::DownLoadFile(const char *szFilePath,const char *url,bool Post, const char *PostData, int PostDataLength){

	OutputDebugString(_T("DownLoad File Starting.\r\n"));
	char szDir[MAX_PATH+1] = "\0";
	memcpy_s(szDir,MAX_PATH,szFilePath,strlen(szFilePath));
	if(!CreateFileDir(szDir))return FALSE;
	HANDLE hFile = CreateFileA(
		szFilePath,
		GENERIC_READ|GENERIC_WRITE,
		FILE_SHARE_READ|FILE_SHARE_WRITE,
		NULL,
		CREATE_ALWAYS,
		FILE_ATTRIBUTE_NORMAL,//FILE_ATTRIBUTE_HIDDEN
		NULL
		);
	if(hFile == INVALID_HANDLE_VALUE)return false;



	//did we get an url?
	if (url == NULL)
	{
		LastError = -1;
		return NULL;
	}
	//get the page and store it in ReceivedData...
	if (Post)
	{
		//use http post...
		if (!PostUrl(url, PostData, PostDataLength)) return NULL;
	}
	else
	{
		//use http get
		if (!OpenUrl(url)) return NULL;
	}
	DWORD dwPos = 0,dwWrited = 1;
	BOOL bReturn = FALSE;
	while(dwWrited > 0)
	{
		InternetReadFile(hIS, ReceivedData, SIZE_STEP_DEFAULT, &dwWrited);
		if(!(bReturn = WriteFile(hFile, ReceivedData, dwWrited, &dwPos, NULL))) break;
		Out(Dbg,_T("DownLoading Files .\r\n"));
	}

//	TCHAR *httpHeader=GetHeaders(url);
	CloseHandle(hFile);
	if(!bReturn)
	{
		OutputDebugString(_T("DownLoad File Failed.\r\n"));
		return false;
	}
	OutputDebugString(_T("DownLoad File Successful.\r\n"));
	return TRUE;
}
コード例 #2
0
ファイル: HttpObj.cpp プロジェクト: killvxk/WebbrowserLock
char* CAmHttpSocket::GetPage(const char *url, bool Post, const char *PostData, int PostDataLength)
{
	//did we get an url?
	if (url == NULL)
	{
		LastError = -1;
		return NULL;
	}
	//get the page and store it in ReceivedData...
	if (Post)
	{
		//use http post...
		if (!PostUrl(url, PostData, PostDataLength)) return NULL;
	}
	else
	{
		//use http get
		if (!OpenUrl(url)) return NULL;
	}
	DWORD rd, dwPos = 0;
	while(InternetReadFile(hIS, ReceivedData + dwPos, SIZE_STEP_DEFAULT, &rd))
	{
		if(rd == 0)break;
		if(rd < SIZE_STEP_DEFAULT)
		{
			m_dwLength = dwPos + rd;
			ReceivedData[m_dwLength] = NULL;
			break;
		}
		else
		{
			dwPos += rd;
			m_dwSize = dwPos + SIZE_STEP_DEFAULT;
			ReceivedData = (char*)realloc(ReceivedData, m_dwSize + 1);
			ReceivedData[m_dwSize + 1] = NULL;
		}
	}

	return ReceivedData;
}
コード例 #3
0
ファイル: npsqueak.c プロジェクト: fniephaus/squeak
static void 
InputCallback(SqueakPlugin *plugin, int *source, XtInputId* id)
{
  int cmd;
  DPRINT("NP: InputCallback()\n");
  if (!plugin->sqwindow)
    {
      /* read sqwindow */
      SetUpSqueakWindow(plugin);
      return;
    }
  Receive(plugin, &cmd, 4);
  switch (cmd) {
  case CMD_GET_URL: 
    GetUrl(plugin);
    break;
  case CMD_POST_URL: 
    PostUrl(plugin);
    break;
  default:
    fprintf(stderr, "Unknown command from Squeak: %i\n", cmd);
  }
}