Oberon ||
Library ||
Module Index ||
Search Engine ||
Definition ||
Module
Ulm's Oberon Library:
WebHandlers
NAME
WebHandlers - HTTP request processing
SYNOPSIS
TYPE Handler = POINTER TO HandlerRec;
TYPE HandlerRec =
RECORD
END;
TYPE Request = POINTER TO RequestRec;
TYPE RequestRec =
RECORD
serverAddress: Networks.Address; (* To distinguish clients on
different ports *)
clientAddress: Networks.Address; (* address of the client *)
method: Streams.Stream; (* requested Method *)
url: InetURLs.URL; (* requested resource *)
versionMajor: SHORTINT; (* of Client *)
versionMinor: SHORTINT; (* of Client *)
headers: HTTPHeaders.HeaderSet;
body: Streams.Stream; (* NIL, if there is no body *)
response: Streams.Stream; (* where to send the response *)
END;
HandleRequestProc = PROCEDURE (handler: Handler; request: Request;
errors: RelatedEvents.Object);
Interface = POINTER TO InterfaceRec;
InterfaceRec =
RECORD
(Objects.ObjectRec)
handleRequest: HandleRequestProc;
END;
PROCEDURE Init(handler: Handler; if: Interface);
PROCEDURE HandleRequest(handler: Handler; request: Request;
errors: RelatedEvents.Object);
DESCRIPTION
The module WebHandlers defines an abstraction to processes a HTTP request
of a client. It searches for the web object identified by the URL and creates a
response. WebObjects is used to obtain the data, to create the status
line, the headers of the response and the body.
Request structure
The Request-record provides all necessary information of a client request.
It contains the message method, the URL to determine the web object, information
about the client used HTTP version, all request headers and if supplied the body of the
client request.
In serverAddress you can find the port of the daemon providing the
request. So you can use one web handler to maintain different ports.
clientAddress provides the address of the client (not yet implemented;
clientAddress is always NIL).
The response-stream ist the network stream to the client. A web handler
must send his responses to that stream.
Providing Web-handlers
Implementations must initialize new instances of web handlers using Init,
specifying an interface if. if only contains the HandleRequest
procedure.
- handleRequest: PROCEDURE(handler: Handler; request: Request; errors: RelatedEvents.Object);
-
is normally called by a Daemon wenn a request occurs. request contains
all necessary information about the request. This request has to be processed by
the Handler and the response must be sent to request.response.
request.response will remain open if it isn't explicitly closed by
HandleRequest (so a client can make repeated request on the same
connection). Because of simultaneous requests, the Implementor must be aware of
creating a reentrant procedure.
Using Web-handlers.
HandleRequest is normally called by a HTTP daemon. In request the caller
provides the split response of the client. If there is an error during the work
it should raised related to errors.
DIAGNOSTICS
WebHandler itself does not generate error events. Only the underlying
implementations of HandleRequest raise errors as RelatedEvents to
the given errors parameter.
SEE ALSO
- InetURLs
-
addresses for web pages
- HTTPHeaders
-
manage HTTP-header fields
- HTTPResponse
-
write HTTP-structures to client stream
- InetHTTPDaemon
-
receiving a request from a client
- RelatedEvents
-
error handling
- Streams
-
stream operations
- WebObjects
-
abstraction for world wide web objects
AUTHOR
Manfred Rueß, University of Ulm
Edited by: borchert, last change: 1998/04/24, revision: 1.1, converted to HTML: 1998/04/24
Oberon ||
Library ||
Module Index ||
Search Engine ||
Definition ||
Module