Rolling the Process
Download
Report
Transcript Rolling the Process
Dyalog’09
Overview of MildServer
Morten Kromberg
Dyalog’09 – Princeton, NJ
Goals and Philosophy
• The goal is to make it possible for ”ordinary”
APL developers to develop web pages
• The ”MildServer” is an experimental platform for
this work.
• What’s the problem, anyway?
MildServer Overview
Dyalog’09 - Princeton
3
What’s the Problem?
POST /linreg.dyalog HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-msapplication, application/vnd.ms-xpsdocument, application/xaml+xml, ... blah blah
blah ...
Accept-Language: da
Content-Type: multipart/form-data; boundary=---------------------------7d83002220638
UA-CPU: x86
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; ... blah blah
...
Content-Length: 2198
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: UserId=mkrom; Session=dOiEkOvDgxAVdTpXZMRhpwCxpalFAI5p2pvbbhTHHAA=
-----------------------------7d83002220638
Content-Disposition: form-data; name="Degree"
1
-----------------------------7d83002220638
Content-Disposition: form-data; name="X"
1
-----------------------------7d83002220638
Content-Disposition: form-data; name="Y"
2
MildServer Overview
Dyalog’09 - Princeton
4
The Desired Answer...
HTTP/1.0 200 OK
Content-Length: 2515
content-type: text/html; charset=utf-8
<html>
<head>
<title>Demo Server</title>
<link href="/Styles/Style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h2>Linear Regression</h2>
<table >
<tr>
<td><form action="/linreg.dyalog" method="post" enctype="multipart/form-data">
<table>
<tr><td ><b>Degree...</b></td>
<td><select " name="Degree" value="1">
<option selected>1</option>
<option>2</option>
<option>3</option>
</select>... of polynomial</td></tr>
MildServer Overview
Dyalog’09 - Princeton
5
What’s The Problem (again)?
• Decode the HTTP Headers and Data
– Make data available to the application developer
• (Detect and) Manage ”Sessions”: Persistence of data
from one request to the next
– A ”Cookie” is a bit of data stored on your PC, which is
transmitted to the server with every request
– A session cookie tracks a user from one page to the next
• Provide Security: Identify the User and
Restrict Access to parts of the Web Site
• Help the application developer generate HTML
– And a bit later (perhaps), more complex controls
MildServer Overview
Dyalog’09 - Princeton
6
BIG Thanks to ”WildHeart”
• I have been allowed to steal code from the
”WildServer” and other servers Stefano
Lanzavecchia has built
– (all the tricky bits about decoding HTTP!)
• WildServer is a more complete, ”more objectoriented” HTTP server developed by Stefano
• MildServer is Mortens ”watered down”
environment
• ”Anyone who is able to write an APL function
should be able to turn it into a web page” ™
MildServer Overview
Dyalog’09 - Princeton
7
A MildServer Page
• Each page is a class which must derive from
MildPage
• It must have a public function called Render
which takes an instance of HTTPRequest as its
argument
• Render must end by calling one of:
– Request.Return (HTML)
– Request.ReturnFile (FileName)
– Request.Fail (HTTPCode)
MildServer Overview
Dyalog’09 - Princeton
8
Page Data
• For each user session, an instance of the page class
is made (object orientation is a good tool for this )
• If your page has Public Fields or Properties,
MildServer will move data from the HTTP request into
your page if the HTTP element has the same name
• Any data inside the instance will survive until the
session ends (times out after inactivity or user LogOut)
MildServer Overview
Dyalog’09 - Princeton
9
Page Data – Example ...
MildServer Overview
Dyalog’09 - Princeton
10
Source Code Management ...
• MildServer is also a demonstration of the ”new
way” of developing Dyalog applications
• ALL the code is in UTF-8 text files, managed by
SALT (the Simple APL Library Toolkit)
• SubVersion (a free source code management
system) is used to manage the source code
• It is available as a download from the APL Wiki
• This does not compromise the way that you
develop APL applications at all ...
MildServer Overview
Dyalog’09 - Princeton
11
MildServer Components
• MildServer is a TCP/IP server which accepts
connections, incoming data, and returns output
• HTTPRequest is a class which decodes an HTTP
Request into APL data
• SimpleAuth is a basic security provider which uses the
HTTP Challenge protocol based on XML input
• SimpleSessions is a simple cookie-based session
manager which preserves application data for the
duration of a session
MildServer Overview
Dyalog’09 - Princeton
12
MildServer Configuration
MildServer Overview
Dyalog’09 - Princeton
13
Open, Modular Design
• Note that the Session Handler and
Authentication components are configurable
• Each one is defined in a script file; you can
enhance them or replace them
• Over time, more and more of the MildServer
should become configurable
• The idea is that the community will build a more
sophisticated shared web framework in APL
MildServer Overview
Dyalog’09 - Princeton
14
My Own ”To Do” List
• Make HTMLInput Class Extensible
• Add optional Authentication Handlers
– Combine SSL and certificates with passwords
– Provide a more elegant security plugin using an
HTML subform rather than the HTTP Challenge
protocol
• Error Logging and Reporting module prototyped
• Run MildServer as a Windows Service
(autostart when Windows starts)
MildServer Overview
Dyalog’09 - Princeton
15
Conclusion
• Proposition:
– MildServer is sufficient for many ”simple” applications
– Anyone who can write an APL function can implement a
web site using MildServer
– Scripted code does not compromise the ”APL Way”
• NO additional components needed (IIS/Apache)
• It is an experiment (but already in ”production” use
in simple applications) ...
– Please take a look and comment, and contribute!
MildServer Overview
Dyalog’09 - Princeton
16