MUG '02
-- 16th Daylight User Group Meeting -- 26 Feb - 1 Mar 2002
HTTP Toolkit
Dave Weininger, Daylight CIS
To be covered:
- HTTP service as program paradigm
- The HTTP toolkit supports the HTTP object
- HTTP toolkit: object properties
- New concepts
- /factory services
- A microserver example: ethanol
- A full-featured example: logpstar
- Other cool stuff.
- ... in conclusion ...
1.
HTTP service as program paradigm
Goals haven't changed much since this was presented at EuroMUG 2000.
- Requirements
- Full-strength delivery of GUI to all kinds of clients
- Non-GUI application programs would be nice, too.
- Network orientation for integration as a tool
- Administration-free program delivery
- Secure operations in a (mainly) stateless environment
- Scale from one machine to LAN to enterprise to www
- Robust. Reliable. Testable. Supportable.
- Compelling motivations
- MIT-X/XView limited future, limited audience
- DCGI right direction but not supportable in long run
- Current information delivery is limited by interfaces
- "Bite the bullet and do it right" is a long term winner
2.
The HTTP toolkit supports the
HTTP object
- An HTTP object represents an HTTP service
- dt_http_alloc() creates one
- dt_http_loop() starts it
- dt_dealloc() destroys it
- Everything else is controlled by object properties
3.
HTTP toolkit:
object properties
- Factory properties are in the "_" namespace
- Very few properties needed for basic operation:
- "_path" -- request path
- "_reply" -- reply content
- "_mime" -- reply type
- Large number of properties allow complete control
- Object-property API is likely basis of Daylight 5.x
4.
New concepts
- Daylight methods
The HTTP toolkit requires the introduction of object methods to the Daylight toolkit API.
In the HTTP toolkit these serve as callbacks, but methods may be used for many other
purposes also. The HTTP toolkit defines five such methods
as HTTP object properties (_init_cb, _loop_cb, _beat_cb, _error_cb, _exit_cb).
Of these, only one (_loop_cb) is needed for basic operation.
- Service domain
This is something that ought to be part of the HTTP protocol,
but it doesn't seem to be, so it was invented as part of the HTTP toolkit.
A service domain is simply a set of IPs which an HTTP server will service.
It may be a network or a list of IPs.
The default service domain is the server's own (A-, B-, or C-class) network,
but it can be set like any other HTTP object property to, for instance, a
subnet or www.
HTTP requests originating from outside the service domain get a 403 Forbidden response.
5.
/factory services
The HTTP toolkit provides a set of built-in resources,
to enhance robustness and convenience.
The caller's _loop_cb method is invoked for /factory URI's;
such requests can be denied (return 403 Forbidden or 404 Not Found)
use the intrinsic service (return 303 Moved Temporarily),
or serviced in the normal manner (overriding intrinsic behavior).
- /factory/etc/
current status and object property information
- /factory/help/
documentation about HTTP toolkit and server usage
- /factory/image/
static images such as the Daylight sunburst logo
- /factory/java/
and /factory/javascript/
.jar, Class and .js resources
6.
A microserver example:
ethanol
You've heard of microbreweries?
Here's a microserver.
$ make ethanol
/opt/SUNWspro/bin/cc -v -Xc -DDP_SOLARIS -D_POSIX_PTHREAD_SEMANTICS -D_REEN
...
$ strip ethanol
$ ls -l ethanol
-rwxr-xr-x 1 dave staff 6748 Feb 23 17:29 ethanol
$ ./ethanol
ethanol server starting up on port 22002
And the link
<A HREF='http://sun2.daylight.com:22002/'>.
The small size of the executable (6748 bytes) is due to linking
against the SMILES and HTTP libraries in run time ...
but any way you cut it, those are 6748 hard-working bytes!
Simple as this example is, it meets the ambitious
requirements listed at the beginning of this talk.
7.
A full-featured example:
logpstar
The 4.81 release will have this as a programming example in contrib,
or something like it.
<A HREF='http://sun2.daylight.com:11053/'>.
8.
Other cool stuff
- Forms
Data from posted forms are available as a sequence of
name-value pairs as the _posts request property.
- File upload
Multipart encoding is supported to allow file upload from
the client's machine. Data is provided as a normal posted
property _value.
Additionally, the "_filename" property is defined.
- Cookies
Netscape cookies are supported to provide a limited
amount of state information.
Default or user-provided encryption is supported.
- Authorization
HTTP 2.0 challenge/authentication protocol is supported.
9.
... in conclusion ...
- The HTTP toolkit provides a powerful method for dissemination of
research information.
- The HTTP toolkit is integrated into the Daylight system and behaves
similarly to other toolkits.
- The HTTP toolkit is slated to be part of Daylight Release 4.81.