Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.90 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Enumerate TWebRequest HTTP header fields
  2. TIdHTTPAppRequestHelper = class helper for TIdHTTPAppRequest
  3.   public
  4.     function GetRequestInfo: TIdEntityHeaderInfo;
  5.   end;
  6.  
  7.   implementation
  8.  
  9.   function TIdHTTPAppRequestHelper.GetRequestInfo: TIdEntityHeaderInfo;
  10.   begin
  11.     Result := FRequestInfo;
  12.   end;
  13.        
  14. procedure Twm.wmWebActionItem1Action(Sender: TObject; Request: TWebRequest;
  15.                  Response: TWebResponse; var Handled: Boolean);
  16. var
  17.   HeadersCount: Integer;
  18.   I: Integer;
  19.   sw: TStreamWriter;
  20. begin
  21.   Response.ContentType := 'text/plain';
  22.   Response.ContentStream := TMemoryStream.Create;
  23.   sw := TStreamWriter.Create(Response.ContentStream);
  24.   try
  25.     HeadersCount := TIdHTTPAppRequest(Request).GetRequestInfo.RawHeaders.Count;
  26.     for I := 0 to HeadersCount - 1 do
  27.       sw.WriteLine(TIdHTTPAppRequest(Request).GetRequestInfo.RawHeaders.Names[I]);
  28.   finally
  29.     sw.Free;
  30.   end;
  31.   Handled := True;
  32. end;