Jump to content

Au3 FastCGI - AuCGI, but faster. ( Generate WebPages behind any WebServer )


arcker
 Share

Recommended Posts

Au3_FastCGI

Arck System.

Version 0.1 Beta

alpha version ( proof of concept ).

Version 0.1 Beta *

What is it ?

Au3 FastCGI is a CGI handler that will run constantly to get request from webservers

The process will send back html code to the webserver.

It’s the same as php or other language that acts as cgi.

FastCGI is powerful since CGI spawn a process on each request. FastCGI works with TCP connection, so it’s always started to handle request.

Some reads : http://www.fastcgi.com/drupal/

Features :

This udf enables FastCGI to be used with autoit.

FastCGI is used by a lot of webservers ( mainly to use php ) to call functions written in other languages. Its main purpose is too use sockets on existants processes instead of stdios to send/receive result and spawn process.

With is, you can spawn your fastcgi “listener” then let it run. A service is in preparation to do so.

You can use any webserver that support FastCGI. Lighttp, apache, and more, make a total third part architecture. The webserver with your firewall can run in linux and Au3_fastcgi_Server can run on a dedicated server.

Multiple instances can run, so many processes can run, to avoid contention and make a bigger webserver.

This UDF uses

  • TCP_Event by kip to boost performances. ( avoid loop )
  • Bininbinary by ward to fastcheck only needed informations. ( avoid uses of multiple structure, can gain 1-2 ms ) ( will be in proper version ) ( not used in FastCGI_Lite )
For now, this udf lets you make webservers in autoit with easy integration. By detaching webserver and fastcgi, you can easily update your webserver.

I’ve attached a script that you rerun your script in scite to test. Simply right-click on autoit icon when running, then click restart, and it will close and tells cite to reload it. Be careful, scite will run active tab.

To use it, you have to think this way :

The main process will handle all of your process code. You have to let the engine function, then add your functions to test it.

When you call http://localhost/test.au3, the script will call “test” function.

If the function doesn’t exists, a custom 404 error is thrown. For now, you can’t set subpages ( like /somepages/test/index.au3 ) only “root” can be called.

The Fast CGI Lite script is my paperboard. You can execute it and test some pages, but it will changed often in the future. Please test your script in an external file.

HOW TO RUN

  • First of all, start the ServerControl.exe, then click start, and reduces it if everything ok. If another process is listening to port 80, close it, or change port in ligttpd config files.
  • Open Au3_FastCGI_Lite.au3 in Scite and run it
  • Open your favorite webbrower and type http://localhost/index.au3

    • You should see a 404 custom page
  • Now go to http://localhost/_all.au3

TO DO LIST

  • Add SubPages Support
  • Add GZip support ( should be on lighttp size, don’t know)
  • Add ability to send/receive files and process them
  • Add Multiple process example
  • Add Session ID or something like that
  • Benchmark TCP Event <> TCP Loop

LIMITATIONS

  • Your code must contain engine code.
  • All of your pages must be functions ( for now, I plan to make something different with an array soon )
  • All au3 code must be added in. You can btw use external files to make more. AutoIt can’t compile code on the fly (as php does ), so your “listener” must be fully stopped and restarted to test changes.
  • Doesn’t support session id ( for now )

DOWNLOAD

http://www.2shared.com/file/UmS1x9Hv/FastCGI.html

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

#include "F:AuCGIhtdocsindex.au3"

#include "F:AuCGIhtdocsRequest_data.au3"

#include "F:AuCGIhtdocsGet_results.au3"

#include "F:AuCGIhtdocsindex_test.au3"

4 file where?

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Link to comment
Share on other sites

#include "F:AuCGIhtdocsindex.au3"

#include "F:AuCGIhtdocsRequest_data.au3"

#include "F:AuCGIhtdocsGet_results.au3"

#include "F:AuCGIhtdocsindex_test.au3"

4 file where?

Don't use au3_fastcgi_server, prefer use au3_fastcgi_lite.au3

you can remove those, they are other test pages ;)

will post update asap.

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

  • 1 year later...

How to use $_FILES Global Var?

i'm use code...

<?php
 $error = "";
 $msg = "";
 $fileElementName = 'fileToUpload';
 if(!empty($_FILES[$fileElementName]['error']))
 {
  switch($_FILES[$fileElementName]['error'])
  {

   case '1':
    $error = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
    break;
   case '2':
    $error = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
    break;
   case '3':
    $error = 'The uploaded file was only partially uploaded';
    break;
   case '4':
    $error = 'No file was uploaded.';
    break;

   case '6':
    $error = 'Missing a temporary folder';
    break;
   case '7':
    $error = 'Failed to write file to disk';
    break;
   case '8':
    $error = 'File upload stopped by extension';
    break;
   case '999':
   default:
    $error = 'No error code avaiable';
  }
 }elseif(empty($_FILES['fileToUpload']['tmp_name']) || $_FILES['fileToUpload']['tmp_name'] == 'none')
 {
  $error = 'No file was uploaded..';
 }else
 {
   $msg .= " File Name: " . $_FILES['fileToUpload']['name'] . ", ";
   $msg .= " File Size: " . @filesize($_FILES['fileToUpload']['tmp_name']);
   //for security reason, we force to remove all uploaded file
   @unlink($_FILES['fileToUpload']);  
 }  
 echo "{";
 echo    "error: '" . $error . "',n";
 echo    "msg: '" . $msg . "'n";
 echo "}";
?>

 

how convert FASTCGI code??

Edited by davidkim

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...