Item4662: Foswiki as a stand alone server
Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release: major
Applies To: Engine
Component:
Branches:
See
TWiki:Codev/TWikiStandAlone
--
TWiki:Main/GilmarSantosJr - 18 Sep 2007
HTTP engine may send wrong
Content-Type
response header for static files ("text/plain" for css files, for example) unless there is a
$HOME/.mime.types
or
$HOME/.media.types
file with the following format:
text/css css
text/html html htm
# ...
Debian has a file like that:
/etc/mime.types
. Copy it to home directory of user running http stand alone. Don't forget to rename to
.mime.types
(notice the initial dot)
--
TWiki:Main.GilmarSantosJr - 19 Sep 2007
HTTP engine could send wrong status line response header for non-HTTP/0.9 clients. Fixed: svn 14943.
--
TWiki:Main.GilmarSantosJr - 19 Sep 2007
-
mime.types
problem fixed: now $TWiki::cfg{MimeTypesFileName} is used.
- auto
restart
feature added to HTTP engine
- Fixed crash after the
TWiki::generateHTTPHeaders
and modifyHeaderHandler
introduction
--
TWiki:Main.GilmarSantosJr - 15 Oct 2007
Added call to
CGI::initialize_globals()
just before call to CGI constructor.
This fix a great bug (and security hole): CGI caches information in global variables (so, it's possible to call constructor multiple times, even if data from STDIN was alredy read), and it was a
serious problem to FastCGI engine, cause those variables were not reinitialized and data (mainly login information, since it is the first posted data most of times) persisted between calls, even if "logout" was used. It was not a problem to CGI engine: since it is executed for every request, it always have a "clean" memory.
CGI::initialize_globals()
is not documented. Care must be taken, since it could be changed in future versions...
Tested with CGI, version 3.15 (distributed with perl 5.8.8)
--
TWiki:Main.GilmarSantosJr - 21 Oct 2007
Finally I'll start to merge this work with core code. In summary, changes are:
- Add the abstraction layer created
- Update code to use it
- Add engine infra-structure
- Add CGI and CLI engines
- Update test framework
- Update some unit tests
- Update documentation
Add the abstraction Layer
This work makes it possible to use TWiki under many execution mechanisms easily. To achieve this, an abstraction layer was created. This layer isolates most part of core code from the details of each mechanism. It's composed of three classes:
- TWiki::Request: responsible for encapsulate request data and provide it to core, independent of which mechanism is in use
- TWiki::Request::Upload: helper class to deal with uploads
- TWiki::Response: container to response data
- TWiki::LoginManager::Session: support for sessions independent from CGI environment
- Update lib/MANIFEST
Add engine infra-structure & default engines
This is the part in charge of dealing with details of execution mechanism. It complements the layer above. It's composed of:
- TWiki::Engine: abstract base class. Must be overridden by each engine.
- TWiki::EngineException: exception class, used by engines.
- TWiki::Engine::CGI: CGI engine.
- TWiki::Engine::CLI: CLI Engine
- bin/twiki_cgi.pl: new start point
- Update lib/MANIFEST
It's also needed to remove old scripts and make them links to
twiki_cgi.pl.
Update REST Interface
There is a script,
bin/rest, that is different from others: it implements it's action without a
TWiki::UI::* class. To make it work in the new way, I modified it to be similar to the others. So the needed changes are:
- Add TWiki::UI::Rest
- Make bin/rest a link to bin/twiki_cgi.pl
- Update lib/MANIFEST
Core Updates
There are many changes that need to be performed within core code in order to get things working:
- Replace TWiki::UI with the new one
- Replace %ENV reads with TWiki::Request method calls
- Replace print=='s with ==TWiki::Response method calls
- Rename $twiki->{cgiQuery} to $twiki->{request}
- Add new field: $twiki->{response}
- Update some default tag handler's
- Eliminate ==die=='s and ==exit=='s
- Add $TWiki::engine variable
- Make TWiki::UTF82SiteCharSet a method
- Update TWiki::writeCompletePage
- Update TWiki::redirect
- Replace CGI class by TWiki::Request when appropriated
- Update TWiki::Func::writeHeader
- Update TWiki::LoginManager
UnitTestContrib updates
There were updates to some unit tests of default plugins and to the UnitTestContrib itself. Main changes were:
- Replace new CGI by new Unit::Request
- Replace ->{cgiQuery} by ->{request} (or
$this->{request}
if test is derived from TWikiFnTestCase
)
- Set charset after the session object is created
Sven stated that plugins must work and be testable in any release, and currently (at least the test) works only with trunk. We agreed to add an abstraction layer class (to use in place of
CGI and
TWiki::Request) that verify version in use and makes itself derived from the right class, so tests work on any version. As soon as I can I'll implement this.
Updates to default plugins
Only WysiwygPlugin needed to be updated. There was a discussion at twiki-dev mailing list and I implemented the proposed solution: pass
TWiki::Response object to REST handlers. The handlers, then, test if there is such parameter and use it or print data directly if there isn't.
Write Unit Tests for the new code
I'll concentrate on this just after solving the compatibility issue of plugin's unit tests.
Documentation updates
Some documents need updates
- TWikiFuncDotPm
- Add TWiki::Response documentation
- Install instructions
- Code comments/docs
--
TWiki:Main.GilmarSantosJr - 18 Jun 2008/21 Jul 2008/04 Oct 2008
excellent
I enabled the unit tests on the trunk a few weeks ago in preparation for you - I think the sooner you merge, the sooner more people can help.
--
TWiki:Main.SvenDowideit - 19 Jun 2008
This work was completed and released some time ago. Closing.
--
CrawfordCurrie - 07 Mar 2013