mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 06:10:34 +01:00
* Post form/file examples
git-svn-id: trunk@17521 -
This commit is contained in:
parent
1ef58e168d
commit
4e43569885
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -2372,6 +2372,10 @@ 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/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
|
||||
packages/fcl-web/examples/httpclient/httppost.pp svneol=native#text/plain
|
||||
packages/fcl-web/examples/httpclient/httppostfile.lpi svneol=native#text/plain
|
||||
packages/fcl-web/examples/httpclient/httppostfile.pp svneol=native#text/plain
|
||||
packages/fcl-web/examples/httpserver/simplehttpserver.lpi svneol=native#text/plain
|
||||
packages/fcl-web/examples/httpserver/simplehttpserver.pas svneol=native#text/plain
|
||||
packages/fcl-web/examples/jsonrpc/demo1/README.txt svneol=native#text/plain
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
<Title Value="HTTP Client application demo"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
@ -35,17 +34,12 @@
|
||||
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="2">
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="httpget.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="httpget"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="fphttpclient.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fphttpclient"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
||||
76
packages/fcl-web/examples/httpclient/httppost.lpi
Normal file
76
packages/fcl-web/examples/httpclient/httppost.lpi
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="Form post example"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<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="1">
|
||||
<Unit0>
|
||||
<Filename Value="httppost.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="httppost"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="10"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<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>
|
||||
30
packages/fcl-web/examples/httpclient/httppost.pp
Normal file
30
packages/fcl-web/examples/httpclient/httppost.pp
Normal file
@ -0,0 +1,30 @@
|
||||
program httppost;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
SysUtils, Classes, fphttpclient;
|
||||
|
||||
Var
|
||||
F : TFileStream;
|
||||
Vars : TStrings;
|
||||
i : integer;
|
||||
begin
|
||||
With TFPHTTPClient.Create(Nil) do
|
||||
begin
|
||||
F:=TFileStream.Create('response.html',fmCreate);
|
||||
try
|
||||
Vars:=TstringList.Create;
|
||||
try
|
||||
For i:=1 to 10 do
|
||||
Vars.Add(Format('Var%d=Value %d',[i,i]));
|
||||
FormPost(ParamStr(1),vars,f);
|
||||
finally
|
||||
Vars.Free;
|
||||
end;
|
||||
finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
end.
|
||||
|
||||
77
packages/fcl-web/examples/httpclient/httppostfile.lpi
Normal file
77
packages/fcl-web/examples/httpclient/httppostfile.lpi
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<UseDefaultCompilerOptions Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="Form post file example"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<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="1">
|
||||
<Unit0>
|
||||
<Filename Value="httppostfile.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="httppostfile"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="10"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<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>
|
||||
28
packages/fcl-web/examples/httpclient/httppostfile.pp
Normal file
28
packages/fcl-web/examples/httpclient/httppostfile.pp
Normal file
@ -0,0 +1,28 @@
|
||||
program httppostfile;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
SysUtils, Classes, fphttpclient;
|
||||
|
||||
Var
|
||||
F : TFileStream;
|
||||
Vars : TStrings;
|
||||
i : integer;
|
||||
begin
|
||||
With TFPHTTPClient.Create(Nil) do
|
||||
begin
|
||||
F:=TFileStream.Create('response.html',fmCreate);
|
||||
try
|
||||
Vars:=TstringList.Create;
|
||||
try
|
||||
FileFormPost(ParamStr(1),'myfile',paramstr(2),f);
|
||||
finally
|
||||
Vars.Free;
|
||||
end;
|
||||
finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user