mORMot and Open Source friends
Check-in [0e2388d919]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:sample "04 - HTTP Client-Server": added authentication to the remote process
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0e2388d919eca1211033982ab965e896e7ffc0ed
User & Date: G018869 2011-10-17 11:44:35
Context
2011-10-17
14:36
added test about per-database encryption in TTestExternalDatabase.CryptedDatabase check-in: 21747e8b91 user: G018869 tags: trunk
11:44
sample "04 - HTTP Client-Server": added authentication to the remote process check-in: 0e2388d919 user: G018869 tags: trunk
11:43
fixed error in case of URI similar to 'root?session_signature=...' check-in: c662eee654 user: G018869 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite3/Samples/04 - HTTP Client-Server/Project04Client.dpr.

24
25
26
27
28
29
30




31
32
33
34
35
36
37
..
48
49
50
51
52
53
54

55
56
     exact Unit1 is used for both static in-memory database engine, or
     with SQLite3 database storage, in local mode or in Client/Server mode: 
     only the TForm1.Database object creation instance was modified
   - look at the tiny size of the EXE (even with SQLite3 engine embedded), less
     than 400KB for the server, and 80KB for the client, with LVCL :)

  Version 1.0 - February 07, 2010




}

program Project04Client;

uses
  Windows,
  Forms,
................................................................................
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Form1.Caption := ' Sample 04 - HTTP Client';
  if ParamCount=0 then
    Server := 'localhost' else
    Server := AnsiString(Paramstr(1));
  Form1.Database := TSQLite3HttpClient.Create(Server,'8080',Form1.Model);

  Application.Run;
end.






>
>
>
>







 







>


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
52
53
54
55
56
57
58
59
60
61
     exact Unit1 is used for both static in-memory database engine, or
     with SQLite3 database storage, in local mode or in Client/Server mode: 
     only the TForm1.Database object creation instance was modified
   - look at the tiny size of the EXE (even with SQLite3 engine embedded), less
     than 400KB for the server, and 80KB for the client, with LVCL :)

  Version 1.0 - February 07, 2010

  Version 1.16
  - added authentication to the remote process

}

program Project04Client;

uses
  Windows,
  Forms,
................................................................................
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Form1.Caption := ' Sample 04 - HTTP Client';
  if ParamCount=0 then
    Server := 'localhost' else
    Server := AnsiString(Paramstr(1));
  Form1.Database := TSQLite3HttpClient.Create(Server,'8080',Form1.Model);
  TSQLite3HttpClient(Form1.Database).SetUser('User','synopse');
  Application.Run;
end.

Changes to SQLite3/Samples/04 - HTTP Client-Server/Project04Server.dpr.

18
19
20
21
22
23
24
25
26
27
28
29
30
31




32
33
34
35
36
37
38
     you should better use our SQLite3i18n unit and the corresponding
     TLanguageFile.StringToUTF8() and TLanguageFile.UTF8ToString() methods
   - note that you didn't need to write any SQL statement, only define a
     class and call some methods; even the query was made very easy (just an
     obvious WHERE clause to write)
   - thanks to the true object oriented modeling of the framework, the same
     exact Unit1 is used for both static in-memory database engine, or
     with SQLite3 database storage, in local mode or in Client/Server mode: 
     only the TForm1.Database object creation instance was modified
   - look at the tiny size of the EXE (even with SQLite3 engine embedded), less
     than 400KB for the server, and 80KB for the client, with LVCL :)


  Version 1.0 - February 07, 2010




}

program Project04Server;

uses
  Forms,
  Unit2 in 'Unit2.pas' {Form1},






|






>
>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
     you should better use our SQLite3i18n unit and the corresponding
     TLanguageFile.StringToUTF8() and TLanguageFile.UTF8ToString() methods
   - note that you didn't need to write any SQL statement, only define a
     class and call some methods; even the query was made very easy (just an
     obvious WHERE clause to write)
   - thanks to the true object oriented modeling of the framework, the same
     exact Unit1 is used for both static in-memory database engine, or
     with SQLite3 database storage, in local mode or in Client/Server mode:
     only the TForm1.Database object creation instance was modified
   - look at the tiny size of the EXE (even with SQLite3 engine embedded), less
     than 400KB for the server, and 80KB for the client, with LVCL :)


  Version 1.0 - February 07, 2010

  Version 1.16
  - added authentication to the remote process

}

program Project04Server;

uses
  Forms,
  Unit2 in 'Unit2.pas' {Form1},

Changes to SQLite3/Samples/04 - HTTP Client-Server/Unit2.pas.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
begin
  Close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Model := CreateSampleModel;
  DB := TSQLRestServerDB.Create(Model,ChangeFileExt(paramstr(0),'.db3'));
  DB.CreateMissingTables(0);
  Server := TSQLite3HttpServer.Create('8080',[DB]);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Server.Free;






|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
begin
  Close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Model := CreateSampleModel;
  DB := TSQLRestServerDB.Create(Model,ChangeFileExt(paramstr(0),'.db3'),true);
  DB.CreateMissingTables(0);
  Server := TSQLite3HttpServer.Create('8080',[DB]);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Server.Free;