Item4662: Foswiki as a stand alone server

Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release: major
Applies To: Engine
Reported By: TWiki:Main.GilmarSantosJr
Waiting For:
Last Change By: CrawfordCurrie
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 DONE

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 DONE

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/ new start point
  • Update lib/MANIFEST

It's also needed to remove old scripts and make them links to

Update REST Interface DONE

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/
  • Update lib/MANIFEST

Core Updates DONE

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}
    • Propagate this change
  • 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 DONE

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 DONE

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 wip

I'll concentrate on this just after solving the compatibility issue of plugin's unit tests.

Documentation updates wip

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 smile 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

ItemTemplate edit

Summary Foswiki as a stand alone server
ReportedBy TWiki:Main.GilmarSantosJr
SVN Range TWiki-4.2.0, Tue, 18 Sep 2007, build 14928
AppliesTo Engine
Priority Enhancement
CurrentState Closed
Checkins TWikirev:14593 TWikirev:14882 TWikirev:14884 TWikirev:14885 TWikirev:14899 TWikirev:14900 TWikirev:14906 TWikirev:14924 TWikirev:14943 TWikirev:15054 TWikirev:15277 TWikirev:15278 TWikirev:15279 TWikirev:15283 TWikirev:15284 TWikirev:15345 TWikirev:15346 TWikirev:15363 TWikirev:15366 TWikirev:15381 TWikirev:15382 TWikirev:15394 TWikirev:15395 TWikirev:15396 TWikirev:15397 TWikirev:15399 TWikirev:15402 TWikirev:15421 TWikirev:15423 TWikirev:15425 TWikirev:15426 TWikirev:15427 TWikirev:15428 TWikirev:15538 TWikirev:15684 TWikirev:16425 TWikirev:16426 TWikirev:16427 TWikirev:16428 TWikirev:16429 TWikirev:16435 TWikirev:16462 TWikirev:16463 TWikirev:16464 TWikirev:16513 TWikirev:16514 TWikirev:16515 TWikirev:16726 TWikirev:16727 TWikirev:16728 TWikirev:16729 TWikirev:16730 TWikirev:16732 TWikirev:16893 TWikirev:16914 TWikirev:16949 TWikirev:16950 TWikirev:16951 TWikirev:16987 TWikirev:17062 TWikirev:17065 TWikirev:17066 TWikirev:17067 TWikirev:17068 TWikirev:17070 TWikirev:17071 TWikirev:17072 TWikirev:17073 TWikirev:17074 TWikirev:17075 TWikirev:17077 TWikirev:17078 TWikirev:17079 TWikirev:17080 TWikirev:17081 TWikirev:17082 TWikirev:17083 TWikirev:17084 TWikirev:17085 TWikirev:17086 TWikirev:17087 TWikirev:17088 TWikirev:17089 TWikirev:17090 TWikirev:17091 TWikirev:17317 TWikirev:17318 TWikirev:17319 TWikirev:17320 TWikirev:17321 TWikirev:17322 TWikirev:17535
TargetRelease major
ReleasedIn n/a
Topic revision: r99 - 07 Mar 2013, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy