by Alfonso Ranieri
DISCLAIMER:
THIS SOFTWARE AND INFORMATION ARE PROVIDED "AS IS".
ALL USE IS AT YOUR OWN RISK, AND NO LIABILITY OR
RESPONSIBILITY IS ASSUMED.
NO WARRANTIES ARE MADE.
1. Introduction
THIS IS THE FIRST VERSION OF HSERV WITH RESUMING.
Hserv was born as an example in rxsocket.library archive, but it become
so large and cute that I decided to release it as a stand alone application.
It is a HTTP 1.0 ARexx server, very configurable and funny.
The main features are:
- run alone or as inetd service in multiple istance listening on different ports;
- run alone or as inetd service;
- accepts GET, HEAD and POST methods
- "If-Modified-Since supported", with a lot of date formats;
- rfc1945 Auth supports;
- rejected-ips;
- mime types read from file, so you can had your mime;
- text parsing;
- in line ARexx functions in html documents;
- ARexx, perl and exe macros;
- may be set to require ident service running at client host;
- configuration GUI.
2. Requirements
hserv needs:
- AmigaOS 2.0 or higher
- ARexx
- Miami or AmiTCP/Genesis. hserv DOESN'T work on Termite.
- rxsocket.library
- rmh.library
- rxasl.library
- rxwiz.library
- wizard.library
NOTA BENE
wizard.library is not present in this archive.
You can download it now.
3. Installation
First of all run the installation script.
Let's suppose you installed hserv in path: (complete path to the drawer).
Then follow this basic installation:
To install hserv as an inetd service:
- If running on AmiTCP
open AmiTCP:db/services and (if not already present) add the line:
http 80/tcp
open AmiTCP:db/inetd.conf and add the line
http stream tcp nowait root C:rxs rxs path:main/hserv.rexx
- If running on Miami
open Miami/DataBase/services window
press "Add" gadget
(if not already present) add the entry:
Name: http
ID: 80
Protocol: tcp
open Miami/DataBase/InetD window
press "Add" gadget
add the entry:
Service: http
Socket: stream
Protocol: tcp
Wait: nowait
User: root
Server: c:rxs
Name: rxs
Args: path:main/hserv.rexx
To install it as stand alone:
run >NIL: <NIL: rx path:main/hserv
(or just rx path:main/hserv)
5. Distribution
hserv is FreeWare.
You are free to detribute it as long as the original archive is kept intact.
Commercial use or its inclusion in other software package is prohibited
without prior consens from the Author.
4. Author
I am: Alfonso Ranieri
My e-mail address is: alfier@iol.t
You can find me on:
- #amigaita ircnet
- #amyita ircnet
My home page is at: http://users.iol.it/alfier
6. Configuration
Configuration options are read from a file, which is the first
argument for hserv.
If no file name is given, hserv tries to open hserv:conf/hserv.conf
Each line of the configuration file is in the form:
<option> <value>
Empty lines, lines beginning with # or ;
lines after the 1024th, chars after the 256th
are ignored during parsing.
Words can be separeted by spaces and tabs.
The options are:
HostName the host name, if none given, hserv tries to obtain it
from the socket name.
Don't set it if you don't know what you are doing
Port the port to use, (of course, only valid if
running as stand alone and can't be changed on the fly)
default 80
Admin any occurence of <!admin> in a text is coverted to
<A HREF="mailto:admin">admin</A>
DocumentDir the dir where documents are
DocumentIndex any request with a null file name is replaced with this
default hserv:htdocs/index.html
CGIDir the directory where CGI macros are. It is used if and only
if a "/cgi-bin/<file>" is received
ErrorLog a flag that indicates if errors must be logged
values are ON OFF SYS
deafult SYS
ErrorFile if ErrorLog is ON, log error in this file
TransferLog a flag that indicates if requests must be logged
values are ON OFF SYS
default OFF
TransferFile if TransferLog is ON, log requests int this file
Auth the auth file
RejectedIP the rejected ip
MimeFile the mime file
Timeout timeout in seconds for the receive request phase
default 300
HostnameLookups a flags that indicates if the server should do a
GetHostByName() on the client ip
values are ON OFF
default OFF
Ident a flag that indicates if the client must have the
ident service running; the server will connect it
and get client ident
values are ON OFF
default OFF
OnlyAmigaClient only Amiga client accepted; clients without the word
"Amiga" in User-Agent field are rejected
values are ON OFF
default OFF
Status status of the server
value are OPENED PAUSED CLOSED
default OPENED
Pri exec priority of the server process
default 0
7. Auth
The Auth file consists of lines in the form:
<pattern> <realm> <login> <pass>
- pattern is an AmigaDOS pattern, that will be applied to the complete
file name requested.
- realm is a symbolic name for the protected space the file(s) belongs to
- login is the login
- pass is the password
Due ARexx limitation I set the max length of login":"pass to max 20 chars.
Anytime a file is requested, after it was parsed in a complete path to a file,
and matches pattern in a line of Auth file, an autentication request is send
to the client.
Try to join TheSecretGarden
you'll need to login with l:secret p:garden
8. RejectedIP
The RejectedIP file consists of lines in the form:
<pattern> <reasone>
- pattern is an AmigaDOS pattern, that will be applied to the ip
of the client
- reasone is the reasone for the k-line. It is send to the client
If the pattern matches the ip, the connection is not accepted.
If a non empty Rejectedip file is given, HostNameLookups is set.
9. Mime
The Mimefile consists of lines in the form:
<mime> <ext> {SP ext}
- mime is a mime type, e.g. <text/html>
- ext is the extension of the file.
Any file with an extension present in the left part of a mime line
is considered to be of that mime.
Default mime is <text/html>.
10. RunTime
hserv has a standard AmigaDOS template:
FILE,PORT/N
- FILE is the configuration file
- PORT is the port to listen to
it only works if hserv is started stand alone
it can be 0 < port > 65535
- if it is not given, it is read from the config file
- if the config file has no PORT options it is set to 80 by default
- if port is 0, the port is searched in the services database
If the server runs as stand alone:
- hserv opens a port called HSERV.PORT where port is the port it is listening at
this port accepts the commands:
- QUIT quit the server
- CONF [file] reload the old file, or a new one
- SHOW open HserPrefs with the current configuration file.
If the config file is modified, the server auto reloads it.
hserv (or better hs.rexx) do these controlls before sending a file:
- good request
- peer info
- Ident
- OnlyAmigaClient
- k-lined ip
- file contains "//" or ":"
- file exists
- Auth
- good request method
11. Parsing
Any time a file of mime <text/*> is encontered, the server makes this parsing
on its' LINES:
changes the string <!ip> with the peer name
changes the string <!user> with the user name, if ident is ON, or unknown
if ident is OFF
changes the string <!userat> with the user user@ip, if ident is ON, or
ip if ident is OFF
changes the string <!admin> with the string
<A HREF="mailto:admin">admin</A>
changes the string <!power> with the string "Powered up with rxsocket.library"
changes the string <!ver> with the string "hserv 6.1"
changes the string <!this> with the current file name
changes the string <!InetDate> with the current date in GMT Internet format
changes the string <!REXX fun> with the output of the function fun, an Arexx
function called on the fly
changes the string <!CGI fun> with the result of the file created by the CGI fun
with the first 2 lines discarded
The parsing is made for all but !CGI then for !CGI, but never recursively for !CGI.
12. CGI
The term CGI refers to:
- ARexx macros
- perl macros
- AmigaOS exe
The type of the macro is parsed from its file name extension:
- ARexx macros must have the extension rexx
- perl CGI macros must have the extension cgi
- AmigaOS execs must have no extension
The directory CGIDir contains all the macro that are called in the form
"/cgi-bin/macro". It is a default directory for general porpouse macros.
Of course, a CGI macro of type perl will work if and only if you have perl
in your path, e.g. you have GeekGadgets installed.
CGI are called with the same arguments in the request.
They must write to stdout:
- first line: "Content-Type:" mime
- second line: (empty)
- rest: data (mime specific)
Macros have their real directory as CurrentDir.
If they are called from a <!CGI fun> the first 2 lines are discarded and
the rest is inserted.
ONLY file with mime text/* are parsed.
13. Bug
- no way to pass cgi macros local vars, like the ip of the client,
the arguments of a get or a post and so on, e.g. like apache does.
That's not a bug:
"If-Modified-Since" works just on AWeb, ask V and IB why, not me.
14. Changes
Changes from version < <!ver>:
- rewritten some functions
- added the gui
15. GUI
hserv cames with a preferences editor GUI.
The GUI can be run via HservPrefs icon/macro.
It's template is:
FILE,PUBSCREEN/K
- FILE the file to load
- PUBSCREEN the screen where to open
(- SERVER internal, do not use)
The GUI is really easy to use, so there isn't so much to say.
At start it searches for:
- a file given as first argument
- conf/hserv.conf if present it exists
If the gui is started by hserv itself via the ARexx command SHOW
an optional gadget "Close server" is present: it closes that istance
of hserv.
16. Resuming
This version of hserv implement a basic file resuming.
Only thi form of "Range:" are accepted:
- a-b
- -b
a-
So it works pretty well with HttpResume.
Let me know about the bug.