Changeset 67 for trunk/Components/CoolWeb/WebServer/UHTTPServer.pas
- Timestamp:
- Dec 25, 2011, 9:40:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Components/CoolWeb/WebServer/UHTTPServer.pas
r61 r67 28 28 29 29 THTTPRequest = class 30 ContentType: string; 31 Content: TMemoryStreamEx; 30 32 Query: TQueryParameterList; 31 33 QueryParts: TListString; … … 34 36 Headers: TStringList; 35 37 Cookies: TCookieList; 38 Post: TQueryParameterList; 36 39 constructor Create; 37 40 destructor Destroy; override; … … 42 45 THTTPResponse = class 43 46 ContentType: string; 44 Stream: TMemoryStreamEx;47 Content: TMemoryStreamEx; 45 48 Headers: TStringList; 46 49 Cookies: TCookieList; … … 126 129 I: Integer; 127 130 begin 128 with HandlerData, Response. Streamdo begin131 with HandlerData, Response.Content do begin 129 132 //Response.Cookies.Values['Test'] := 'Halo'; 130 133 //Response.Cookies.Values['Test2'] := 'Halo2'; … … 134 137 135 138 WriteString('<a href="?ServerInfo">Refresh</a>'); 139 140 WriteString('<h5>Request HTTP content:</h5>'); 141 WriteStream(Request.Content, Request.Content.Size); 136 142 137 143 WriteString('<h5>Request HTTP headers</h5>'); … … 151 157 end; 152 158 159 WriteString('<h5>Request HTTP POST</h5>'); 160 for I := 0 to Request.Post.Count - 1 do begin; 161 WriteString(Request.Post.Strings[I] + '<br/>'); 162 end; 163 164 165 WriteString('<h5>Response HTTP content:</h5>'); 166 WriteStream(Response.Content, Response.Content.Size); 167 153 168 WriteString('<h5>Response HTTP headers</h5>'); 154 with Response. Streamdo169 with Response.Content do 155 170 for I := 0 to Response.Headers.Count - 1 do begin; 156 171 WriteString(Response.Headers.Strings[I] + '<br/>'); … … 166 181 procedure THTTPServer.ErrorResponse(HandlerData: THTTPHandlerData); 167 182 begin 168 with HandlerData, Response. Streamdo begin183 with HandlerData, Response.Content do begin 169 184 WriteString('<html><body>' + Format(SPageNotFound, [Request.Path]) + '</body></html>'); 170 185 end; … … 193 208 Response.Headers.Values['Content-Type'] := GetMIMEType(Copy(ExtractFileExt(FileName), 2, 255)); 194 209 BinaryFile := TFileStream.Create(FileName, fmOpenRead); 195 Response. Stream.WriteStream(BinaryFile, BinaryFile.Size);210 Response.Content.WriteStream(BinaryFile, BinaryFile.Size); 196 211 BinaryFile.Destroy; 197 212 end else 198 with Response. Streamdo begin213 with Response.Content do begin 199 214 WriteLn(Format(SFileNotFound, [Request.Path])); 200 215 WriteString('<html><body>' + Format(SFileNotFound, [Request.Path]) + '</body></html>'); … … 219 234 constructor THTTPResponse.Create; 220 235 begin 221 Stream:= TMemoryStreamEx.Create;236 Content := TMemoryStreamEx.Create; 222 237 Cookies := TCookieList.Create; 223 238 Headers := TStringList.Create; … … 226 241 destructor THTTPResponse.Destroy; 227 242 begin 228 Stream.Free;243 Content.Free; 229 244 Headers.Free; 230 245 Cookies.Free; … … 255 270 constructor THTTPRequest.Create; 256 271 begin 272 Post := TQueryParameterList.Create; 257 273 Query := TQueryParameterList.Create; 258 274 QueryParts := TListString.Create; 259 275 Headers := TStringList.Create; 260 276 Cookies := TCookieList.Create; 277 Content := TMemoryStreamEx.Create; 261 278 end; 262 279 263 280 destructor THTTPRequest.Destroy; 264 281 begin 282 Content.Free; 283 Post.Free; 265 284 Query.Free; 266 285 QueryParts.Free;
Note:
See TracChangeset
for help on using the changeset viewer.