Re: [NEWBIE] [Offtopic] A HTTP webserver.

From: Erwin S. Andreasen (erwin@ANDREASEN.COM)
Date: 09/15/98


On Mon, 14 Sep 1998, Jeffrey Margolis wrote:

> quick info that is for there eyes only with out having to log on?  Well if it
> hasnt i would really like to try and was wondering if some one could point me
> in the right direction such as.  well the basics of how to code a http server,
> but anything would help.  I dont know if this is possible(with my coding
> experiences) or if it is just wishfull thinking.

It's fairly simple to have a basic HTTP server - just bind()/listen() to
some port you want your HTTP stuff to be at, listen for incoming
connection , put them in a special CON_STATE and then wait for the request
line, i.e. GET|POST <url> <version>.

It gets more tricky to do user authenthication - as someone else said, if
your data is mostly static, you might be better off using your webserver
and its authentication.

If you really want to, or your data is dynamic (e.g. I use it to let
people view boards, areas, userlist and edit files from their web browser)
however, you can look at RFC 1945, which describes the HTTP 1.0 protocol -
it has authentication described.

Basically, when the user first accesses a page that needs authentication
and does not have it, you would need to send back 401 Authentication
Required response. In the headers, you would need to supply:

WWW-Authenticate: Basic realm="Realm"

The "realm" is just a name for your webpages that share authentication
data.

Then, the user's browser will ask them for username / password, and send
back another request. This time, the user's request will contain the
header:

Authorization: basic base64string

The base64string is a base64 encoded password:username. E.g. the user's
browser puts in Drylock:qwerty if it used username Drylock and password
qwerty, then base64-encodes it.

Base 64 encoding is described in some other RFC, 1521 I think :)


--
 =============================================================================
<erwin@andreasen.com>      Herlev, Denmark              UNIX System Programmer
<URL:http://www.abandoned.org/drylock/>     <*>         (not speaking for) DDE
 =============================================================================


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST