Gambas httpd server

So you have written that new, must have program. Let us see it here.
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Gambas httpd server

Post by ocoquet »

Hi all, happy new year from France,

Here is an httpd server based on a class file.
It is not completely http1.0 compliant but, i work for that.
Actualy, this is what it can do:

Serve html pages from a directory.
Serve Index.html if no page is given by the navigator.
Serve err404 page from directory when asked page do not exist.
give the control to a main program when a *.gbp page is asked by the navigator (something like php ;) ).
and much more.....

Look in the web forum for details of this first beta.

Enjoy
Olivier
The downloadable file is complete source (class + Main form sample), it will be upgraded every time I'll add functionality or bug corrections. Last changes will be described in below messages.
Attachments
http-server-0.0.17.tar.gz
Sources of httpd gambas server class & sample
Version 0.0.17 - see below for last changes.(18/01/21)
(84.62 KiB) Downloaded 387 times
Last edited by ocoquet on Monday 18th January 2021 5:54pm, edited 5 times in total.
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

Hi all, I'm proud to show you last changes of Gambas Basic Httpd server class.
V 0.0.12 (03/01/2021)
Download upgraded version at first message bottom

- Added log file writer (httpd_log.log) in application folder
- Added log_flag public variable in class header ( True = log active, False= log inactive).

Regards from France
Olivier
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

Hi all, I'm proud to show you last changes of Gambas Basic Httpd server class.
V 0.0.13 (04/01/2021)
Download upgraded version at first message bottom

Big changes and small bugs corrections:

-Bug correction, if requested page is not present in web-docs, no error 404 is written in log_file, it's now corrected.
-Bug Correction, http_log file have no extension, now it has a *.log extension.
-Bug Correction, Server-sockets was never closed, they are now closed each time a page is completely sent.

-NEW Function, public encrypt function in class to encrypt and save logins and passwords in password file.
-NEW Function, public function for verifying login and password with registered version in password file.
- A new public var is added to the class, it determine the crypto-mode as this:
Public Crypt_Mode As Integer = 1 'mode d'encryptage utilisateurs et password 1=DES, 2=MD5,3=SHA256,4=SHA512

Tips:
- There is some controls added to the sample form which is present in source code.
- Tow textboxes (login & password). When you fill them, click on create to register them encrypted in password file. Click on test login to see if
login and password are retrieved from password file.
- The sample index.html page in web-docs is modified with login fields and button to test passwords, look at the main class to see how this work.
It's my first *.gbp sample.

regards
Olivier
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

No news today, I'm working on Session cookies.....


Regards
Olivier
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

Hi All, here are last changes (07/01/2021)
V0.0.14

- Add a Session time Function and public var class to define how long a session is valid
- Add a Session validity test Function
- Add a redirection Function to redirect user who have an invalid session.
- Add a send / recept cookie Function
- Add some Function to read/write/update session last time use.
- <needCookie> balise is now used in pages to signify than it need a valid session to be viewed

- Add samples in sample form and webpages:
- Valid session test (on Form)
- Test login (webpage as index.html)
- Test form value send and value display on other page
- Information page on invalid session.

Enjoy !
Olivier
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

Hi all, Gambas HTTP server v 0.0.15 is coming soon.

Lot off add and some minor bugs corrected.

- Add tow vars in class header to reflect total live connections and total pages viewed.
- Add Tow lcd viewer on sample form to reflect state of the tow new var.
- Add tow var in class header to determine name and class of *.gbp treatment procedure to call (must be initialized just after instantiation).
- Add carrying "POST" method to send form parameters.
- Add sample html page to demonstrate user creation, you must be logged in before use (create your own user from sample form before).
- Modifies function to see if user exist before create.
- User name are now wrote in clear text in userpwd file.

- Bug corrected: send cookies are now available for all sub folder of web-docs

Regards
Olivier
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

Hi All, here are last changes (12/01/2021)
V0.0.16

- Sample Treatment procedure now use named arguments vs numbering, this allow order inversion in form field in the form at design time without influence on detection of them.

- Correction of bug in invalid session detection (a "u" replaced a "U" in code ).

- Correction of bug in Cookie sending (a "u" replaced a "U" in code, re )

- userpwd file is now created if not present (first run), this create an Admin user with default password "password" which is defined in a var in the header of class (must be changed by your master program just after instantiation.

- Add of ListUsers Function which return list of registered users in an array of strings.

- Sample Treatment procedure send good link if user exist when trying to create an existing user("admin/..." replaced "../...").


Enjoy

Olivier Coquet
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

Hi All,
New version is coming soon.

There is now, tow formats:
- Complete source with sample form to test
- Component package which can be integrated directly in Gambas as component.

Regards
Olivier
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Gambas httpd server

Post by BruceSteers »

Funny though
looking at my gambas components i see gambas already has gb.httpd an embedded http server
If at first you don't succeed , try doing something differently.
BruceS
ocoquet
Posts: 36
Joined: Friday 18th December 2020 7:56am

Re: Gambas httpd server

Post by ocoquet »

Hi All, here are last changes (18/01/2021)
V0.0.17

- Finalization of the modification of the processing procedure, all the arguments are now exploited by their name and not by their order of arrival (more secure).
- Added the main Mime types up to the letter "J".
- Modified the userpwd.txt file which now contains the date of last connection of a user.
- Changed the ListUser function which now returns the username and last connection in the string array (including the date of last connection).
- The Processing function is called systematically on all pages with the argument "Replace", this allows to replace text between {} by what you want (for example for a version number on each page).
- Added a variable at the head of the class, indicating the version of the class.
- Transformation into a component and first tests in this form.
- Modification of the ListUser function which now returns an array of collections (Name,Date,Time).

Translated with www.DeepL.com/Translator (free version)

Enjoy,
Olivier Coquet
Olivier Coquet
Gambas Dev
Le Forum développeur Gambas
Post Reply