1 "CGI define: #PrintStream &parents: {Parsing BasicParser} &slots: {#rootElement}."
3 lobby define: #CGI &parents: {Cloneable} &slots:
4 {#variables -> Dictionary new.
5 #out -> Console writer.
6 #xhtml -> Xml XHTMLPrintStream.
7 #postValues -> Dictionary new.
8 #getValues -> Dictionary new.
11 cgi@(CGI traits) parseQueryString: queryString into: dict
13 (queryString splitWithAny: {$&}) do:
15 s := (x as: cgi postString) reader.
17 value := Net URLPathEncoder convert: s upToEnd.
18 dict at: key put: value].
21 cgi@(CGI traits) on: resource
23 cgi out := resource writer.
24 cgi xhtml := xhtml newOn: cgi out.
30 [variables := variables new.
31 cgi on: cgi out resource.
32 postValues := postValues new.
33 getValues := getValues new. ]
36 cgi@(CGI traits) handleCurrentRequest
38 cgi variables := Environment variables.
40 (cgi variables at: 'CONTENT_LENGTH' ifAbsent: [Nil]) ifNotNilDo:
42 cgi parseQueryString: (Console reader next: (contentlength as: Integer)) into: cgi postValues].
43 (cgi variables at: 'QUERY_STRING' ifAbsent: [Nil]) ifNotNilDo:
45 cgi parseQueryString: query into: cgi getValues].
48 Image startupActions at: #CGI put:
49 [CGI new handleCurrentRequest].