Browse Source

+ Sample application for HTTPApplication and file server

git-svn-id: trunk@17633 -
michael 14 years ago
parent
commit
f093210fa7

+ 2 - 0
.gitattributes

@@ -2369,6 +2369,8 @@ packages/fcl-web/examples/combined/wmlogin.pp svneol=native#text/plain
 packages/fcl-web/examples/combined/wmusers.lfm svneol=native#text/plain
 packages/fcl-web/examples/combined/wmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/combined/wmusers.pp svneol=native#text/plain
+packages/fcl-web/examples/httpapp/testhttp.lpi svneol=native#text/plain
+packages/fcl-web/examples/httpapp/testhttp.pp svneol=native#text/plain
 packages/fcl-web/examples/httpclient/httpget.lpi svneol=native#text/plain
 packages/fcl-web/examples/httpclient/httpget.pas svneol=native#text/plain
 packages/fcl-web/examples/httpclient/httppost.lpi svneol=native#text/plain

+ 190 - 0
packages/fcl-web/examples/httpapp/testhttp.lpi

@@ -0,0 +1,190 @@
+<?xml version="1.0"?>
+<CONFIG>
+  <ProjectOptions>
+    <Version Value="9"/>
+    <General>
+      <Flags>
+        <MainUnitHasCreateFormStatements Value="False"/>
+        <MainUnitHasTitleStatement Value="False"/>
+        <UseDefaultCompilerOptions Value="True"/>
+      </Flags>
+      <MainUnit Value="0"/>
+      <ResourceType Value="res"/>
+      <UseXPManifest Value="True"/>
+      <Icon Value="0"/>
+      <ActiveWindowIndexAtStart Value="0"/>
+    </General>
+    <i18n>
+      <EnableI18N LFM="False"/>
+    </i18n>
+    <VersionInfo>
+      <StringTable ProductVersion=""/>
+    </VersionInfo>
+    <BuildModes Count="1" Active="Default">
+      <Item1 Name="Default" Default="True"/>
+    </BuildModes>
+    <PublishOptions>
+      <Version Value="2"/>
+      <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+      <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
+    </PublishOptions>
+    <RunParams>
+      <local>
+        <FormatVersion Value="1"/>
+        <LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+      </local>
+    </RunParams>
+    <Units Count="7">
+      <Unit0>
+        <Filename Value="testhttp.pp"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="testhttp"/>
+        <EditorIndex Value="0"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="1"/>
+        <CursorPos X="7" Y="10"/>
+        <UsageCount Value="20"/>
+        <Loaded Value="True"/>
+      </Unit0>
+      <Unit1>
+        <Filename Value="fpwebfile.pp"/>
+        <UnitName Value="fpwebfile"/>
+        <IsVisibleTab Value="True"/>
+        <EditorIndex Value="5"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="59"/>
+        <CursorPos X="45" Y="76"/>
+        <UsageCount Value="10"/>
+        <Loaded Value="True"/>
+      </Unit1>
+      <Unit2>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/fphttp.pp"/>
+        <UnitName Value="fphttp"/>
+        <EditorIndex Value="6"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="188"/>
+        <CursorPos X="1" Y="196"/>
+        <UsageCount Value="10"/>
+        <Loaded Value="True"/>
+      </Unit2>
+      <Unit3>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/fphttpapp.pp"/>
+        <UnitName Value="fphttpapp"/>
+        <EditorIndex Value="1"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="14"/>
+        <CursorPos X="31" Y="20"/>
+        <UsageCount Value="10"/>
+        <Loaded Value="True"/>
+      </Unit3>
+      <Unit4>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/custhttpapp.pp"/>
+        <UnitName Value="custhttpapp"/>
+        <EditorIndex Value="2"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="35"/>
+        <CursorPos X="30" Y="39"/>
+        <UsageCount Value="10"/>
+        <Loaded Value="True"/>
+      </Unit4>
+      <Unit5>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/fphttpserver.pp"/>
+        <UnitName Value="fphttpserver"/>
+        <EditorIndex Value="3"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="18"/>
+        <CursorPos X="24" Y="39"/>
+        <UsageCount Value="10"/>
+        <Loaded Value="True"/>
+      </Unit5>
+      <Unit6>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/httpdefs.pp"/>
+        <UnitName Value="HTTPDefs"/>
+        <EditorIndex Value="4"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="1005"/>
+        <CursorPos X="42" Y="1038"/>
+        <UsageCount Value="10"/>
+        <Loaded Value="True"/>
+      </Unit6>
+    </Units>
+    <JumpHistory Count="13" HistoryIndex="12">
+      <Position1>
+        <Filename Value="testhttp.pp"/>
+        <Caret Line="23" Column="3" TopLine="1"/>
+      </Position1>
+      <Position2>
+        <Filename Value="testhttp.pp"/>
+        <Caret Line="8" Column="44" TopLine="1"/>
+      </Position2>
+      <Position3>
+        <Filename Value="fpwebfile.pp"/>
+        <Caret Line="1" Column="1" TopLine="1"/>
+      </Position3>
+      <Position4>
+        <Filename Value="testhttp.pp"/>
+        <Caret Line="29" Column="44" TopLine="1"/>
+      </Position4>
+      <Position5>
+        <Filename Value="fpwebfile.pp"/>
+        <Caret Line="63" Column="22" TopLine="48"/>
+      </Position5>
+      <Position6>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/custhttpapp.pp"/>
+        <Caret Line="39" Column="30" TopLine="35"/>
+      </Position6>
+      <Position7>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/fphttpserver.pp"/>
+        <Caret Line="35" Column="38" TopLine="18"/>
+      </Position7>
+      <Position8>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/httpdefs.pp"/>
+        <Caret Line="623" Column="33" TopLine="613"/>
+      </Position8>
+      <Position9>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/httpdefs.pp"/>
+        <Caret Line="1012" Column="7" TopLine="1009"/>
+      </Position9>
+      <Position10>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/httpdefs.pp"/>
+        <Caret Line="281" Column="71" TopLine="263"/>
+      </Position10>
+      <Position11>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/httpdefs.pp"/>
+        <Caret Line="1014" Column="21" TopLine="1010"/>
+      </Position11>
+      <Position12>
+        <Filename Value="../../../../../FPC/trunk/packages/fcl-web/src/base/httpdefs.pp"/>
+        <Caret Line="660" Column="21" TopLine="627"/>
+      </Position12>
+      <Position13>
+        <Filename Value="fpwebfile.pp"/>
+        <Caret Line="77" Column="60" TopLine="48"/>
+      </Position13>
+    </JumpHistory>
+  </ProjectOptions>
+  <CompilerOptions>
+    <Version Value="10"/>
+    <Parsing>
+      <SyntaxOptions>
+        <UseAnsiStrings Value="False"/>
+      </SyntaxOptions>
+    </Parsing>
+    <Other>
+      <CompilerPath Value="$(CompPath)"/>
+    </Other>
+  </CompilerOptions>
+  <Debugging>
+    <Exceptions Count="3">
+      <Item1>
+        <Name Value="EAbort"/>
+      </Item1>
+      <Item2>
+        <Name Value="ECodetoolError"/>
+      </Item2>
+      <Item3>
+        <Name Value="EFOpenError"/>
+      </Item3>
+    </Exceptions>
+  </Debugging>
+</CONFIG>

+ 31 - 0
packages/fcl-web/examples/httpapp/testhttp.pp

@@ -0,0 +1,31 @@
+{$mode objfpc}
+{$H+}
+program testhttp;
+
+uses
+  SysUtils, fphttpapp, fpwebfile;
+
+Procedure Usage;
+
+begin
+  Writeln('Usage : testhttp DocumentRoot [Port]');
+  Writeln('Where');
+  Writeln(' Documentroot   location to serve files from. It is mapped to location /files');
+  Writeln(' Port            port to listen on (default 8080)');
+  Halt(1);
+end;
+
+begin
+  if (ParamCount<1) or (ParamCount>2) then
+    usage;
+  if (ParamCount=2) and (StrToIntDef(ParamStr(2),-1)=-1) then
+    usage;
+  RegisterFileLocation('files',ParamStr(1));
+{$ifdef unix}
+  MimeTypesFile:='/etc/mime.types';
+{$endif}
+  Application.Initialize;
+  Application.Port:=StrTointDef(ParamStr(2),8080);
+  Application.Title:='HTTP Demo application';
+  Application.Run;
+end.