tclhttpd the tcl web server

8
Tcl/2k Conference, slide 1 TclHttpd The Tcl Web Server Brent Welch <[email protected]> www.scriptics.com/tclhttpd ftp.scriptics.com/pub/tcl/httpd

Upload: xaviera-bowers

Post on 31-Dec-2015

22 views

Category:

Documents


0 download

DESCRIPTION

TclHttpd The Tcl Web Server. Brent Welch www.scriptics.com/tclhttpd ftp.scriptics.com/pub/tcl/httpd. Goals and Experiences. Embeddable, Extensible Web Server Add web interface to your application License server, DHCP server, Mail List Server - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 1

TclHttpdThe Tcl Web Server

Brent Welch

<[email protected]>

www.scriptics.com/tclhttpd

ftp.scriptics.com/pub/tcl/httpd

Page 2: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 2

Goals and Experiences

Embeddable, Extensible Web Server– Add web interface to your application– License server, DHCP server, Mail List

Server

General Purpose Web Server– Page Templates– Built-in form handlers– sunscript.sun.com– www.scriptics.com

Page 3: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 3

Architecture for Extensibility

HTTP Protocol

URL Dispatch

App-Direct CGI

Doc

Template

Your ApplicationFileSystem

OtherProcess

Page 4: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 4

Architecture for Extensibility

URL Dispatch– Implement a URL sub-tree, interpret

meaning of URL path

Application-Direct– Maps a URL to a Tcl Procedure. Maps form

data to procedure arguments.

Document Templates– Procedure calls, variable references inside

HTML pages

General Doc-Type handlers

Authentication hook

Page 5: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 5

Url Dispatch: Partition Hierarchy

Url_PrefixInstall prefix command inThreadUrl_PrefixInstall /resource ResourceDispatch 0

/resource/status

Page 6: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 6

Application-DirectMap URL to Tcl Procedure

Direct_Url /status Status

proc Status/doc { {pattern *} {sort hits} } {# Display URLs matching $pattern# Sort display by name or hit countreturn $html

}

/status/doc?pattern=/images*&sort=name

Missing parameters get default value, or “”

Return value of proc is the page

Set alternate content-types, not just text/html

Page 7: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 7

Document Templates: HTML+Tcl

Use Tcl to general complex HTML for navigation

Put simple calls into pages[scriptics::header “Title” lev1 lev2 lev3]

Cache template output in plain .html file

Form handlers – Embed calls to handle incoming form data– “Self-posting forms” repopulate fields, then

redirect to the next page when everything is OK

Page 8: TclHttpd The Tcl Web Server

Tcl/2k Conference, slide 8

32 K File Fetch

32 K file

0

10

20

30

40

50

60

70

80

90

0 2 4 6 8 10 12

S erver

Apache Dell-400

TclHttpd Dell 400

IIS 4 Dell-450

TclHttpd Dell 450

Apache Sparc-270

AOLserver Sparc-270

Netscape

TclHttpd Sparc-270

Apache Sparc-75x2

AOLserver Sparc-75x2

TclHttpd Sparc-75x2