I am writing a webserver in C++, using Winsock. It is complete, except for one thing.
Global:
char HtmlWhole[1000];
This code sends the requested page/file to the client. The problem is, that every file I send using that function comes out like this:Code:int SendFile(char *FileName) { HANDLE hFile; DWORD dwNumRead; BOOL bFile; char FilePath[1000]; char Response[1000]; sprintf(FilePath, "c:\\webserver\\%s", FileName); hFile = CreateFile(FilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); bFile = ReadFile(hFile, HtmlWhole, sizeof(DWORD)*256, &dwNumRead,NULL); bFile = CloseHandle(hFile); sprintf(Response, "HTTP/1.1 200 OK\r\nDate: Sun, 05 Jun 2005 22:15:06 GMT\r\nContent-Length: %d\r\nContent-Type: text/html\r\nCache-Control: private\r\nServer: Server/1.0\r\n\r\n", strlen(HtmlWhole)); printf(Response); send(httpClient, Response, sizeof(Response), 0); send(httpClient, HtmlWhole, sizeof(HtmlWhole), 0); return 0; }
http://img296.echo.cx/img296/5924/html1ne.jpg
When I printf the File Output, it printf the HTML code fine. But when I send it to the client, it shows up like that.
TIA..



LinkBack URL
About LinkBacks


