Hi all,
Out of sheer curiousity and my want to learn HTTP. I've decided to build a webserver in PB, using what I have learned from my perl proxy script that I used to spy on how my web browser interacts with the web. HTTP has proven simple enough to understand. I've decided to build a this PB webserver for grins and even try to implement CGI capability. Just piecing together what I learn from RFC's and my little proxy app. If anyone cares I'll release the source as I go along. Keep in mind I'm doing this for grins and learn what HTTP servers really do, which is seemingly very little. I noticed there was a sample webserver along with my PB install, which I have glanced at, but decided its better to just build from scratch rather than figure out existing code. Plus, that way I completly understand what the hell I wrote. I'll be more than happy to disclose what I've learned to those that want to know. After this I might just finish that mail server I've been working on.
PB based webserver
i bet more than one person will be interested in the results!
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Fred I know, but I'm talking about going above and beyond what that one can do. I'm talking CGI support and all kinds of stuff. I did look at the example, but decided to do a new one from scratch, since that be easier for me than to canabalize the existing code. Also supporting alot more than just serving a few simple HTML pages.Fred wrote:There is already a webserver in the example folder which works for linux and windows.
Perl/Python/PHP is VERY easy to implement and support in a web server, How ever ASP/.net is not, I never managed to get it running with mine but i gave that up a long time ago,
PHP is by far the easiest to implement
1) When a requested file matches the MIME type for PHP, Get the real location of the file by using the Eviroment Veriable 'PATH_TRANSLATED'
2) Second, Open a pipe to php.exe (normally in C:\Php) and call the script location as a paremeter.
3) The output data from php.exe will be the result of the executed php file, Then you just send this information to the browser
Enviroment Veriable, Opening a pipe and getting the ouput can be used very easily from El_Choni's CGI lib, or all the sources for opening pipe and env veriable is on the CodeArchiv
For the others you will have to research it or tare an open source web server apart
PHP is by far the easiest to implement
1) When a requested file matches the MIME type for PHP, Get the real location of the file by using the Eviroment Veriable 'PATH_TRANSLATED'
2) Second, Open a pipe to php.exe (normally in C:\Php) and call the script location as a paremeter.
3) The output data from php.exe will be the result of the executed php file, Then you just send this information to the browser
Enviroment Veriable, Opening a pipe and getting the ouput can be used very easily from El_Choni's CGI lib, or all the sources for opening pipe and env veriable is on the CodeArchiv
For the others you will have to research it or tare an open source web server apart
Ahh, I didnt relealise you were working under linux, Guess you can't use the CGI lib or any of the examples i suggested from the codearchiv.
Surly it wouldnt require to write a lib for it, Correct me if im wrong because i really don't know anything about Linux, But this should work?
As i said that may not work at all, but worth a shot? and maybe this page might help with redirecting pipes
http://www.cpqlinux.com/redirect.html
Also, If you wish i can give you the source to my partitaly coded web server, It has directory traverse protection, Directory listing, Mime types but i stopped because i got bored :s so its vulnerable to buffer overflows, I just extended the PB web server example.
Surly it wouldnt require to write a lib for it, Correct me if im wrong because i really don't know anything about Linux, But this should work?
Code: Select all
exec php.exe>stdout.outhttp://www.cpqlinux.com/redirect.html
Also, If you wish i can give you the source to my partitaly coded web server, It has directory traverse protection, Directory listing, Mime types but i stopped because i got bored :s so its vulnerable to buffer overflows, I just extended the PB web server example.


