support for php5.6.30 master v0.6.0
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Mon, 10 Jul 2017 09:53:21 +0000 (11:53 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Mon, 10 Jul 2017 09:53:21 +0000 (11:53 +0200)
README
php-ancillary.c
test001.php

diff --git a/README b/README
index 6d85e24..e1fb464 100644 (file)
--- a/README
+++ b/README
@@ -5,3 +5,28 @@ $ ./configure
 $ make
 $ su
 # make install-modules
+
+
+How to test it
+==============
+
+configure PHP:
+add /etc/php5/cli/conf.d/30-ancillary.ini with content: 
+
+vvvvv
+; configuration for php ancillary module
+; priority=30
+extension=ancillary.so
+^^^^^
+
+configure apache2:
+-----------------
+
+In /etc/apache2/sites-enabled edit http default configuration:
+ProxyPass /php-ancillary/test001.php fd:///tmp/test001.sock keepalive=Off connectiontimeout=5 timeout=3
+
+run test daemon with:
+./test001.php
+
+and browse the web page:
+http://<your-domain>/php-ancillary/test001.php
index 9ca16fd..b79a92a 100644 (file)
@@ -149,7 +149,13 @@ PHP_FUNCTION(ancillary_getstream);
  
 // list of custom PHP functions provided by this extension
 // set {NULL, NULL, NULL} as the last record to mark the end of list
-static function_entry ancillary_getstream[] = {
+static
+#if ZEND_MODULE_API_NO >= 20131226
+ zend_function_entry
+#elif ZEND_MODULE_API_NO >= 20010901
+ function_entry
+#endif
+ ancillary_getstream[] = {
     PHP_FE(ancillary_getstream, NULL)
     {NULL, NULL, NULL}
 };
@@ -236,6 +242,10 @@ PHP_FUNCTION(ancillary_getstream)
     }
     shutdown(fd_out[1], SHUT_RDWR);
     close(fd_out[1]);
+    write(1, "HEADERS[", 8);
+    write(1, headers, curpos);
+    headers[curpos] = '\0';
+    write(1, "]\n", 2);
     ZVAL_STRING(zheaders, headers, 1);
     free(headers);
 
@@ -263,7 +273,7 @@ PHP_FUNCTION(ancillary_getstream)
 
     if (stream == NULL)        {
         pefree(sock, 0);
-        return NULL;
+        return;
     }
     php_stream_to_zval(stream, return_value);
 }
index fd2e1f4..4a829b5 100755 (executable)
@@ -15,17 +15,33 @@ umask($old_umask);
 
 $new_socket = stream_socket_accept($list);
 
-$fp = ancillary_getstream($new_socket);
+$stream_info = "";
+
+$fp = ancillary_getstream($new_socket, $stream_info);
 printf("FP: %d\n", $fp);
 
+stream_set_blocking ($fp, FALSE);
 
 if ($fp == FALSE)
     printf("ERROR\n");
 else
     printf("GOOD\n");
 
-fwrite($fp, "DI QUI CI PASSO2");
+$from = fread($fp, 4096);
+printf("FROM: [%s]\n", $from);
+
+$body = "<html><title>Ancillary Test 001</title><body>HERE I AM</body></html>\n";
+
+fwrite($fp, "HTTP/1.0 200 OK\r\n");
+fwrite($fp, "Content-type: text/html\r\n");
+fwrite($fp, "X-Savannah: rapatal\r\n");
+// fwrite($fp, sprintf("Content-length: %d\r\n", strlen($body)));
+fwrite($fp, "\r\n");
+
+fwrite($fp, $body);
+
 fflush($fp);
 fclose($fp);
 
-?>
\ No newline at end of file
+print_r($stream_info);
+?>