[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] HTTP-Server



"Erwin S. Andreasen" wrote:
> 
> On Thu, 9 Dec 1999, Joachim Holst wrote:
> 
> > Ooops.. Stavfelsnisse har varit i farten. Det skullle juu givetvis vara
> > mellan varje paket :-)
> > Det som är intressant (tycker jag i alla fall), är att den "felaktiga"
> > informationen inte verkar komma i början på varje paket. Utan ibland
> > verkar det komma som att det kommer i början och ibland i slutet.
> 
> øh, tjo.. vis os noget kode, det kan jeg forstå :)


Det kan jag väl göra. Vet inte om jag vågar, för det är tyvärr microsoft
format.

Har provat lite på två sätt. Dels att ta bort de första 9 bytes i
bufferten, vilket
inte hjälpte och dels ta bort de 9 sista i bufferten vilket inte hjälpte
det heller.

För övrigt, så saknar jag MAN sidor i wintoy. Deras MSDN lib på X gig är
mer eller mindre
värdelös.

/Jocke!

<--- Code --->
#include <afxwin.h>
#include <afxinet.h>
#include <process.h>
#include <windows.h>


#include <stdio.h>
#include <iostream.h>
#include <string.h>

int main(int argc, char **argv) {
	
	CHttpConnection* pServer = NULL;
	CHttpFile* pFile = NULL;
	CString strServerName="www.kde.org";
	//int
	INTERNET_PORT nPort = 80;
	CString strObject = ""; 
	CString szHeaders = "Accept: text/*, audio/*";
	CString test = "";
	char szBuff[1024];
	char *tszBuff;
	DWORD dwRet;

	FILE *outfile = fopen("index.html","wt");

	CInternetSession cses("Test"); // = new CInternetSession();
	pServer = cses.GetHttpConnection(strServerName,nPort);

	pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
strObject);
	pFile->AddRequestHeaders(szHeaders);
	pFile->SendRequest();
	pFile->QueryInfoStatusCode(dwRet);
	
	// Progress info.
	cout << "strObject = " << strObject << endl;
	cout << "Checking HTTP status" <<endl;
	cout << "HTTP Status = " << dwRet << endl;
	if (dwRet == HTTP_STATUS_OK)
	{
		cout << "Getting page" << endl; // Just progressinfo.

		UINT nRead = pFile->Read(szBuff, 1023);
		fprintf(outfile,"%s",szBuff);
		memset(szBuff,'\0',1023); // Nollar bufferten. Vill inte ha
skräptecken.

		/*
		UINT nRead = pFile->Read(szBuff, 1023);
		fprintf(outfile,"%s",szBuff);
		memset(szBuff,'\0',1023); // Nollar bufferten. Vill inte ha
skräptecken.
		*/

		// Skriver ner sidan till en fil..
		while (nRead>0){
			nRead = pFile->Read(szBuff, 1023);
			
			/*
			//Stegar fram en temporär pekare 9 steg för att bli av med
"skräpinfo" i början.
			tszBuff = szBuff;
			for(int i=0;i<9;i++)
				tszbuff++;
			*/
			szBuff[1015]='\n'; // Tar bort de 9 sista tecknen soom är hämtade för
att slippa skräpinfo.
			//fprintf(outfile,"%s",tszBuff); // skriver ut den temporära
bufferten
			fprintf(outfile,"%s",szBuff);
			memset(szBuff,'\0',1023); // Nollar bufferten. Vill inte ha
skräptecken.	
		 }
	}
	fclose(outfile);
	delete pFile;
	return TRUE;
}


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *