modified: LICENSE
authorroot <root@binbash.home.lan>
Thu, 13 May 2010 20:56:10 +0000 (13 22:56 +0200)
committerroot <root@binbash.home.lan>
Thu, 13 May 2010 20:56:10 +0000 (13 22:56 +0200)
modified:   README
fixed port at   examples/hello_world.php
new simplified version of examples/hello_world_forks.php

LICENSE
README
examples/fill_server_variables.php [deleted file]
examples/hello_world.php
examples/hello_world_forks.php
examples/mistral.php [deleted file]

diff --git a/LICENSE b/LICENSE
index e5d224f..f6584f4 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1 +1 @@
-The license debat has not yet been started. So for now the license will be LGPL.
+The license debate has not yet been started. So for now the license will be LGPL.
diff --git a/README b/README
index 076f8ac..25cdb65 100644 (file)
--- a/README
+++ b/README
@@ -1,10 +1,9 @@
 Mistral
-
-
+-------
 The PHP extension you have in front of you allows you to run a
-webserver from inside PHP. This allows you to run a standalone
-application as server, giving it all the benefits of an easy
-to learn and write language plus secure deployment.
+webserver from inside your PHP application. This allows you to
+run a standalone application as server, giving it all the benefits
+of an easy to learn and write language plus secure deployment.
 
 It is currently /in development/, this means that the code you
 can find here is not ready for production yet, unless you are
@@ -14,33 +13,34 @@ could be encountered is out of memory situations because of
 garbage collector incidents.
 
 This code has been written because of /extreme/ performance
-improvements in compare to a standard SAPI clients or HipHop.
+improvements in comparison to standard SAPI clients like FastCGI
+or mod_php.
 We suggest you to use this code behind a reverse proxy such
-as Varnish or Cherokee.
-
-
-Dependencies;
-The code requires libev to compile and run, and gets is major
-speed improvement from this great framework.
-
+as Varnish, haproxy or the Cherokee Webserver.
 
-How to use;
-phpize
-./configure
-make
-make install
-add extension=mistral.so to your php.ini, see the examples
-directory for the typical Hello World type of application.
 
+Dependencies
+------------
+The code requires libev to compile and run, and gets it's major
+speed improvement from this great library.
 
-Known issues;
-Memory usage might become a problem.
 
+Installation
+------------
+1.) phpize
+2.) ./configure
+3.) make
+4.) make install
+5.) add extension=mistral.so to your php.ini, see the examples
+    directory for the typical Hello World type of application.
 
-Stefan de Konink, 2010-02-21
+We hope you find this extension useful and
+you will create high performance web sites using it 
 
+Stefan de Konink & Michael Maier, 2010-05-13
 
-Information request;
 
-German/English -- Michael
-Dutch/English  -- Stefan
+Information request
+-------------------
+Dutch/English  -- Stefan (stefan@konink.de)
+German/English -- Michael (maier@b2host.de)
\ No newline at end of file
diff --git a/examples/fill_server_variables.php b/examples/fill_server_variables.php
deleted file mode 100644 (file)
index c3be5cf..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-                    // Get first line from client
-                    do {
-                        $input = fgets($conn);
-                    } while( !feof($conn) && $input == "" );
-
-                    if ( $input !== false ) {
-                        $inputParsed  = preg_split('/[\s]+/', $input );
-                    }
-
-                    $HTTP_HEADERS = array();
-                    //while( !feof($conn) && ($keepAlive == false || $keepAlive > time()-$keepAliveTimeout) && ($input  = fgets($conn) ) != "\r\n" ) {
-                    while( !feof($conn) && ($input = fgets($conn) ) != "\r\n" ) {
-                        if( preg_match('/([^:]+): (.*)/', $input, $matches) ) {
-                            $HTTP_HEADERS[ strtolower($matches[1]) ] = trim($matches[2]);
-                        }
-                    }
-
-                    if( count($HTTP_HEADERS) ) {
-                        $_SERVER['REQUEST_METHOD']   = strtoupper( $inputParsed[0] );
-                        $_SERVER['REQUEST_URI']      = $inputParsed[1];
-                        $_SERVER['SERVER_PROTOCOL']  = strtoupper( $inputParsed[2] );
-
-                        $remoteIp = explode( ':', stream_socket_get_name( $conn, true ) );
-                        $_SERVER['REMOTE_ADDR']      = $remoteIp[0];
-                        $_SERVER['REMOTE_PORT']      = $remoteIp[1];
-
-                        $_SERVER['HTTP_HOST'] = $HTTP_HEADERS['host'];
-                        $_SERVER['HTTP_USER_AGENT'] = $HTTP_HEADERS['user-agent'];
-                        $_SERVER['HTTP_ACCEPT'] = $HTTP_HEADERS['accept'];
-                        $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $HTTP_HEADERS['accept-language'];
-                        $_SERVER['HTTP_ACCEPT_ENCODING'] = $HTTP_HEADERS['accept-encoding'];
-                        $_SERVER['HTTP_ACCEPT_CHARSET'] = $HTTP_HEADERS['accept-charset'];
-                        $_SERVER['HTTP_KEEP_ALIVE'] = $HTTP_HEADERS['keep-alive'];
-                        $_SERVER['HTTP_CONNECTION'] = $HTTP_HEADERS['connection'];
-                        $_SERVER['HTTP_COOKIE'] = $HTTP_HEADERS['cookie'];
-
-                        $_SERVER['SERVER_SOFTWARE']  = '/^_^\istral Enterprise PHP v1.00';
-
-                        $parsed_uri = parse_url($_SERVER['REQUEST_URI']);
-                        parse_str($parsed_uri['query'], $_GET);
-
-                        $_SERVER['argv'] = array(0 => $parsed_uri['query']);
-                        $_SERVER['argc'] = count($_SERVER['argv']);
-                        $_SERVER['GATEWAY_INTERFACE'] = 'CGI/1.1';
-                        $_SERVER['SCRIPT_NAME'] = $parsed_uri['path'];
-                        $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
-                        $_SERVER['QUERY_STRING'] = $parsed_uri['query'];
-
-                        //print_r($_SERVER);
-                        //print_r($_GET);
-                        //print_r($parsed_uri);
-
-                        // Determine supported compression method
-                        $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
-                        $deflate = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate');
-                        $encoding = $gzip ? 'gzip' : ($deflate ? 'deflate' : 'none');
-
-                        // Check for buggy versions of Internet Explorer
-                        if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') &&
-                            preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches)) {
-                            $version = floatval($matches[1]);
-
-                            if ($version < 6)
-                                $encoding = 'none';
-
-                            if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1'))
-                                $encoding = 'none';
-                        }
-                    }
-?>
index ae68f11..00b009c 100644 (file)
@@ -5,8 +5,8 @@ function my_cool_callback($http_request) {
        return array('status_code' => '200 OK', 'connection' => 'close', 'content-type' => 'text/plain', 'body' => 'Hello World');
 }
 
-# Bind Webserver on all ips with port 8802, timeout > 0 == keep-alive
-mistral_init('0.0.0.0', 6901, 0);
+# Bind Webserver on all ips with port 8081, timeout > 0 == keep-alive
+mistral_init('0.0.0.0', 8081, 0);
 
 # Setup callback function which gets called after each client request
 mistral_register_callback("my_cool_callback");
dissimilarity index 88%
index 8e09683..9571cbe 100644 (file)
@@ -1,47 +1,36 @@
-<?php
-class HelloWorldApp extends Mistral
-{
-    public static function main($http_request) {
-                #print_r($http_request);
-
-                #xhprof_enable();
-                self::parse_headers($http_request);
-                #$xhprof_data = xhprof_disable();
-                #print_r($xhprof_data);
-
-                $output = "Hello World!";
-        $answer = array('status_code' => '200 OK',
-                        'connection' => $_SERVER['HTTP_CONNECTION'],
-                        'content-type' => 'text/html',
-                        'content-length' => strlen($output),
-                        'body' => $output);
-                return $answer;
-        }
-}
-
-
-$maxChildren = 4;
-$startport = 8080;
-while( $cntChildren < $maxChildren ) {
-    $cntChildren++;
-        $startport++;
-
-        $pid = pcntl_fork();
-        if ($pid == -1) {
-                echo "Warning: Cannot spawn child process!!!\n";
-        }
-        elseif($pid) {
-        // Parent process
-        }
-        else {
-                echo 'Spawn Child [' . getMyPid() . '] Port ' . $startport . "\n";
-                $app = new HelloWorldApp('0.0.0.0', $startport, 3);
-                $app->register_callback('HelloWorldApp::main');
-                $app->run();
-        }
-}
-
-while(true) {
-        sleep(1);
-}
-?>
+<?php
+function my_cool_callback($requests) {
+    $requests['HTTP_CONNECTION'] = isset($requests['HTTP_CONNECTION']) ? $requests['HTTP_CONNECTION'] : 'close';
+
+    $output = "Hello World!";
+    $answer = array('status_code' => '200 OK',
+                'connection' => $requests['HTTP_CONNECTION'],
+                'content-type' => 'text/html',
+                'content-length' => strlen($output),
+                'body' => $output);
+    return $answer;
+}
+
+$maxChildren = 4;
+$startport = 8080;
+while( $cntChildren < $maxChildren ) {
+    $cntChildren++;
+    $startport++;
+
+    $pid = pcntl_fork();
+    if ($pid == -1) {
+        echo "Warning: Cannot spawn child process!!!\n";
+    } elseif($pid) {
+        // Parent process
+    } else {
+        echo 'Spawn Child [' . getMyPid() . '] Port ' . $startport . "\n";
+        mistral_init('0.0.0.0', $startport, 5);
+        mistral_register_callback('my_cool_callback');
+        mistral_start();
+    }
+}
+
+while(true) {
+    sleep(1);
+}
+?>
diff --git a/examples/mistral.php b/examples/mistral.php
deleted file mode 100644 (file)
index 2cc026c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-class Mistral
-{
-        public function __construct($ipaddress = '127.0.0.1', $port=8081, $keepalive=3) {
-                mistral_init($ipaddress, $port, $keepalive);
-        }
-
-        public function register_callback($callback_func) {
-                mistral_register_callback($callback_func);
-        }
-
-        public function run() {
-                mistral_start();
-        }
-
-        public function parse_headers($header) {
-                $lines = explode("\n", $header);
-                $first_line = explode(' ', array_shift($lines));
-
-                $_SERVER['REQUEST_METHOD']   = strtoupper($first_line[0]);
-                $_SERVER['REQUEST_URI']      = $first_line[1];
-                $_SERVER['SERVER_PROTOCOL']  = strtoupper($first_line[2]);
-
-                foreach( $lines as $line ) {
-                        $line = trim($line);
-                        if( $line == '' ) continue;
-                        $parts = explode(': ', $line);
-                        if( isset($parts[0]) ) {
-                                $parts[0] = strtoupper($parts[0]);
-                                if( $parts[0] == 'COOKIE' ) {
-                                        $cookies = explode('; ', $parts[1]);
-                                        foreach( $cookies as $cookie ) {
-                                                $cookie_parts = explode('=', $cookie);
-                                                $_COOKIE[$cookie_parts[0]] = $cookie_parts[1];
-                                        }
-                                } else {
-                                        $_SERVER['HTTP_'.str_replace('-', '_', $parts[0])] = $parts[1];
-                                }
-                        }
-                }
-
-                $parsed_uri = parse_url($_SERVER['REQUEST_URI']);
-                parse_str($parsed_uri['query'], $_GET);
-
-                $_SERVER['argv'] = array(0 => $parsed_uri['query']);
-                $_SERVER['argc'] = count($_SERVER['argv']);
-                $_SERVER['GATEWAY_INTERFACE'] = 'CGI/1.1';
-                $_SERVER['SCRIPT_NAME'] = $parsed_uri['path'];
-                $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
-                $_SERVER['PATH_TRANSLATED'] = __PATH__;
-                $_SERVER['QUERY_STRING'] = $parsed_uri['query'];
-                $_SERVER['DOCUMENT_ROOT'] = '/';
-                if( !isset($_SERVER['HTTP_CONNECTION']) ) {
-                        $_SERVER['HTTP_CONNECTION'] = $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' ? 'keep-alive' : 'close';
-                }
-        }
-}
-?>