$ 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
// 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}
};
}
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);
if (stream == NULL) {
pefree(sock, 0);
- return NULL;
+ return;
}
php_stream_to_zval(stream, return_value);
}
$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);
+?>