AgentBase for SICStus Prolog
The package consist of the following modules:
HTTP handler
The module http
These two methods are used to send data back to the HTTP requester.
A HTTP header is sent automatically with content type set to text/html
if no header has yet been sent.
If any of the above steps fails, the user is not authenticated and
a challenge must be sent:
Example
The code of a simple web server example can be found here:
webserver.pl
Copyright © 2001
SICS AB, All Rights Reserved.HTTP
HTTP is a package that enable SICStus developers to use the web
as interface to their programs.
Using the HTTP server
Initialization
The handler uses the module http to access information in the request
and respond to it.
HTTP Authentication
With the HTTP server it is simple to use basic authentication to
authenticate users.
http:authorization(HttpRequest,basic,BasicCookie)
base64:b64decode(BasicCookie,UserInfo)
lists:append(User,[0':|Password],UserInfo)
AuthField = field('WWW-Authenticate',"Basic realm=\"Test Authentication\""),
http:send_error(HttpResponse,unauthorized,[AuthField])
Note that basic authentication transmitts any passwords over
Internet in plain text. Webfile
Webfile uses the HTTP server to return static files from any specified
file directory.