Changeset 27 for branches/lazarus/Common/UCGIApplication.pas
- Timestamp:
- Sep 10, 2010, 8:09:21 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/lazarus/Common/UCGIApplication.pas
r23 r27 28 28 TCGIApplication = class 29 29 private 30 function FormatOutput(Data: string): string;31 30 public 32 31 Headers: TStringList; … … 35 34 Output: TStringList; 36 35 Query: TQueryParameterList; 36 QueryParts: TStringListEx; 37 BaseURL: string; 37 38 constructor Create; 38 39 destructor Destroy; override; … … 54 55 Output := TStringList.Create; 55 56 Query := TQueryParameterList.Create; 57 QueryParts := TStringListEx.Create; 56 58 end; 57 59 … … 63 65 Cookies.Free; 64 66 Query.Free; 67 QueryParts.Free; 65 68 inherited Destroy; 66 69 end; … … 80 83 81 84 // Parse query string 82 Query.Parse(EnvVars.Values['QUERY_STRING']); 85 if Length(EnvVars.Values['QUERY_STRING']) > 0 then 86 if EnvVars.Values['QUERY_STRING'][Length(EnvVars.Values['QUERY_STRING'])] = '/' then 87 EnvVars.Values['QUERY_STRING'] := Copy(EnvVars.Values['QUERY_STRING'], 1, 88 Length(EnvVars.Values['QUERY_STRING']) - 1); 89 QueryParts.Explode('/', EnvVars.Values['QUERY_STRING']); 90 if Pos('?', EnvVars.Values['REQUEST_URI']) > 0 then 91 Query.Parse(Copy(EnvVars.Values['REQUEST_URI'], 92 Pos('?', EnvVars.Values['REQUEST_URI']) + 1, 93 Length(EnvVars.Values['REQUEST_URI']))); 83 94 84 95 Execute; … … 97 108 98 109 // Emit page content 99 //Output.Text := FormatOutput(Output.Text);100 110 for I := 0 to Output.Count - 1 do begin 101 111 WriteLn(Output[I]); … … 115 125 Output.Add('</table>'); 116 126 end; 117 118 function TCGIApplication.FormatOutput(Data: string): string;119 var120 BlockStart, BlockEnd: Integer;121 Indention: Integer;122 Indention2: Integer;123 Line: string;124 Command: string;125 begin126 Result := '';127 Indention := 0;128 Indention2 := 0;129 while Data <> '' do begin130 //WebWrite('.');131 BlockStart := Pos('<', Data);132 BlockEnd := Pos('>', Data);133 if BlockStart > 1 then begin134 BlockEnd := BlockStart - 1;135 BlockStart := 1;136 end;137 Line := Trim(Copy(Data, BlockStart, BlockEnd));138 //WebWriteLn(Line);139 if Length(Line) > 0 then140 if Line[1] = '<' then begin141 if Data[BlockStart + 1] = '/' then begin142 Indention := Indention - 2;143 Indention2 := Indention;144 end else begin145 if Pos(' ', Line) > 0 then Command := Copy(Line, 2, Pos(' ', Line) - 2)146 else Command := Copy(Line, 2, Length(Line) - 2);147 //WebWriteLn(Command + ' ' + IntToStr(Indention));148 if Pos('</' + Command + '>', Data) > 0 then Indention := Indention + 2;149 //WebWriteLn(IntToStr(Indention) + ',' + IntToStr(Indention2));150 end;151 end;152 if Line <> '' then Result := Result + StrRepeat(' ', Indention2) + Line + #13#10;153 Data := Copy(Data, BlockEnd + 1, Length(Data));154 Indention2 := Indention;155 end;156 end;157 158 127 159 128 { TCookieList }
Note:
See TracChangeset
for help on using the changeset viewer.