Gambas httpd server
Posted
#1
(In Topic #541)
Regular

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
<COLOR color="#408000">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.</COLOR>
Sources of httpd gambas server class & sample
Version 0.0.17 - see below for last changes.(18/01/21)
Posted
Regular

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
Posted
Regular

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
- 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
Posted
Regular

Regards
Olivier
Posted
Regular

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
Posted
Regular

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
Posted
Regular

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
Posted
Regular

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
Posted
Banned
looking at my gambas components i see gambas already has gb.httpd an embedded http server
Posted
Regular

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
Posted
Regular

It's not mine
Regards
Olivier
1 guest and 0 members have just viewed this.





