up: HTTP     index Zimbu documentation

CLASS HTTP.Server @public

summary

     

The actual HTTP server.

The defaults are set to use URL "http://localhost" and low verbosity.

NEW(port) @public  Create a new HTTP server on port port.
$setVerbosity(level) @public  Set the verbosity for the server to level.
$setBase(base) @public  Setting the base URL allows servlets to use it.
$setFileRoot(root) @public  Set the directory where files for FileServlet can be found.
$addServlet(servlet) @public  Add a servlet. The server will ask each servlet if it can handle a request.
$addPage(page) @public  Add a ZUT page. This will make the page according to the page argument available and create a servlet for it.
$addPage(title, template, path) @file  Add a ZUT page with title, template method template for URL path.
$redirect(from, to) @public  Generate a "301 moved permanently" response.
$openInBrowser(page) status @public  Open page in a browser, for localhost and the port number of the server.
$quit() @public  Tell the server to quit.
$waitForExit() @public  Wait until the server exits.
 

members (alphabetically)

     

PROC NEW(int port) @public

     

Create a new HTTP server on port port.

PROC $addPage(ZUT.Page page) @public

     

Add a ZUT page. This will make the page according to the page argument available and create a servlet for it.

PROC $addPage(string title, ZUT.HtmlFunc template, string path) @file

     

Add a ZUT page with title, template method template for URL path.

This is shorthand for:

 ZUT.Page page = NEW(title)
 page.setBody(template)
 page.addPath(path)
 $addPage(page)

PROC $addServlet(HTTP.Servlet servlet) @public

     

Add a servlet. The server will ask each servlet if it can handle a request.

The servlets are invoked in the order they have been added. The first one that returns

FUNC $openInBrowser(string page) status @public

     

Open page in a browser, for localhost and the port number of the server.

This has the effect of invoking SYS.openInBrowser() for http://localhost:{port}/{page}

PROC $quit() @public

     

Tell the server to quit.

PROC $redirect(string from, string to) @public

     

Generate a "301 moved permanently" response.

A simple way to add a RedirectServlet and set the from and to URLs.

PROC $setBase(string base) @public

     

Setting the base URL allows servlets to use it.

PROC $setFileRoot(string root) @public

     

Set the directory where files for FileServlet can be found.

PROC $setVerbosity(HTTP.Verbosity level) @public

     

Set the verbosity for the server to level.

PROC $waitForExit() @public

     

Wait until the server exits.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0