The SimpleWeb
interface fetches the contents of a URL. If there are
any errors or if the URL is not of an acceptable type, an approrpriate
message is returned as the contents of the page. In addition, the
SimpleWeb
interface maintains a cache of pages.
INTERFACESimpleWeb ; IMPORT Thread, Web; TYPE ExtensionType = RECORD ext: TEXT; type: Web.MIMEType; subType: TEXT; END; CONST DefaultAccepts = ARRAY OF TEXT {(* no wild cards; sorry *) "text/html", "text/plain", "image/x-xbitmap", "image/gif", "image/jpeg", "image/ppm", "image/pbm", "image/pgm", "image/pnm"}; PROCEDURE Setup(READONLY a: ARRAY OF ExtensionType); PROCEDURE Fetch ( url : TEXT; READONLY accepts: ARRAY OF TEXT := DefaultAccepts; reload : BOOLEAN := FALSE; server : Web.T := NIL ): Web.Page RAISES {Thread.Alerted};
Fetch the URL and return its contents. By default, pages are grabbed from a local cache, ifurl
is in the cache, or from the server's local cache, if the server maintains a cache. Whenreload
isTRUE
, the request always goes to the server; moreover, the server will explicitly not use its own cache, if it maintains one.If the
url
cannot be retreived for any reason, or if the requestedurl
is not of type listed in theaccepts
parameter, then an object of typetext/plain
is returned whosebody
contains an appropriate message.
END SimpleWeb.