Changeset 67 for trunk/Components/CoolWeb/WebServer/UHTTPServerCGI.pas
- Timestamp:
- Dec 25, 2011, 9:40:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Components/CoolWeb/WebServer/UHTTPServerCGI.pas
r61 r67 6 6 7 7 uses 8 Classes, SysUtils, UHTTPServer, SpecializedList ;8 Classes, SysUtils, UHTTPServer, SpecializedList, IOStream; 9 9 10 10 type … … 53 53 I: Integer; 54 54 HandlerData: THTTPHandlerData; 55 InputStream: TIOStream; 56 Line: string; 57 Buffer: string; 58 Count: Integer; 55 59 begin 56 60 HandlerData := THTTPHandlerData.Create; 57 61 with HandlerData do try 62 // Load headers 63 try 64 InputStream := TIOStream.Create(iosInput); 65 SetLength(Buffer, 1000); 66 repeat 67 Count := InputStream.Read(Buffer[1], Length(Buffer)); 68 Request.Content.Write(Buffer[1], Count); 69 until Count = 0; 70 finally 71 InputStream.Free; 72 end; 73 74 //repeat 75 // ReadLn(Line); 76 //until Line = ''; 77 78 // Load data 79 if Request.Headers.IndexOfName('Content-length') <> -1 then 80 try 81 InputStream := TIOStream.Create(iosInput); 82 Request.Content.CopyFrom(InputStream, StrToInt(Request.Headers.Values['Content-length'])); 83 finally 84 InputStream.Free; 85 end; 86 58 87 // Load environment variables 59 88 for I := 0 to GetEnvironmentVariableCount - 1 do begin … … 80 109 SessionStorage.Load(HandlerData); 81 110 82 Response.Stream.Clear; 111 // Load post data 112 if EnvVars.IndexOfName('REQUEST_METHOD') <> -1 then begin 113 if EnvVars.Values['REQUEST_METHOD'] = 'POST' then begin 114 Request.Content.Position := 0; 115 Buffer := Request.Content.ReadString; 116 Request.Post.Parse(Buffer); 117 end; 118 end; 119 120 Response.Content.Clear; 83 121 Response.Headers.Values['Content-type'] := 'text/html'; 84 122 … … 105 143 106 144 // Emit page content 107 Stream.Position := 0;108 WriteLn( Stream.ReadString);145 Content.Position := 0; 146 WriteLn(Content.ReadString); 109 147 end; 110 148 finally … … 118 156 begin 119 157 inherited; 120 with HandlerData, Response. Streamdo begin158 with HandlerData, Response.Content do begin 121 159 WriteString('<h5>' + SEnvironmentVariables + '</h5>'); 122 160 WriteString('<table border="1">');
Note:
See TracChangeset
for help on using the changeset viewer.