Advertisement

simple http server

Started by December 21, 2003 08:33 PM
4 comments, last by logout 21 years, 1 month ago
Okay I am in the prosess off writing a simple web server ( it will just contain text + only show 1 page ) The problem is now that when i try to connect to the server ( listing on port 80 ) Under Opera i get this error: "Could not connect to remote server" Altru I can see it start to load the page then the error msgbox suddenly pops up. Here is the stuff that I am sending and recving from the server: recving:

GET /test.html HTTP/1.1

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1) Opera 7.0  [en]

Host: 127.0.0.1

Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1

Accept-Language: en

Accept-Charset: windows-1252, utf-8, utf-16, iso-8859-1;q=0.6, *;q=0.1

Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0

Connection: Keep-Alive, TE

TE: deflate, gzip, chunked, identity, trailers

the stuff im sending:

HTTP/1.0 200 OK

Date: Mon, 22 Dec 2003 2:19:45 GMT

Server: SomeWebServ

Keep-Alive: timeout=15, max=100

Connection: Keep-Alive

Content-Type: text/html

Content-Length: 52

<html><body><h1>Hurray</h1>bla bla</body></html>
WHY WONT IT LOAD THE FRIGGIN PAGE ????
Does your server actually get past an accept() call?
Advertisement
yes ..

I do check all my recv() and send() for connection close and for SOCKET_ERROR.

I call WSAGetLastError() at the end of the app and it returns '0


[edited by - LogouT on December 21, 2003 10:08:42 PM]
I found the bug with some help from Ethereal ( realy nice app btw )

The problem was that after "Content-Length: 52" i only had
1 \r\n. And therefor the "body" of the site was sendt as a header.

I added 1 \r\n\ after "Content-Length: 52" and it worked.

*now its : "Content-Length: 52\r\n\r\n" *

happy xmas :D
LoneRunner has a nice HTTP server done in MS C++. I based my little webserver on it.

Zero (LoneRunner's server) has two bugs that I know of;
1) www.zeroserveddomain.com/../whatever works (at least on windows), that is, windows commands could be inserted. You could even open com ports (www.zeroserveddomain.com/com1)
2) % sequences can cause page faults; try www.zeroserveddomain.com/space%2 and it'll most likely hang.

On top of that it only implements the get request and returns no other information in the HTTP header other than the return code.



[ Galactic Conquest | Bananas | My dead site | www.sgi.com | Goegel ]

[edited by - Kurioes on December 24, 2003 8:13:02 PM]
Hey, since we''re talking about the Zeroo server, could anyone with experience help? I''ve set it up, and whenever I try to connect to it, I get a 404 error, and nothing else. I''ve set all the parameters in the conf file as I would, yet still nothing. In the console screen is says "123.123.123.123:1234 GET /index.html" But still returns nothing. Any ideas how I can get it to work?

This topic is closed to new replies.

Advertisement