Commits

Ruslan Osmanov committed 5f11617

Change: EventHttpRequest::sendError's reason param made optional
Tiny fixes

  • Participants
  • Parent commits 9f754cc
  • Tags 1.4.0-beta

Comments (0)

Files changed (4)

classes/http_request.c

 }
 /* }}} */
 
-/* {{{ proto void EventHttpRequest::sendError(int error, string reason);
+/* {{{ proto void EventHttpRequest::sendError(int error[, string reason = NULL]);
  * Send an HTML error message to the client.
  */
 PHP_METHOD(EventHttpRequest, sendError)
 {
 	php_event_http_req_t *http_req;
 	long                  error;
-	char                 *reason;
+	char                 *reason = NULL;
 	int                   reason_len;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls",
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s!",
 				&error, &reason, &reason_len) == FAILURE) {
 		return;
 	}

classes/listener.c

 	TSRMLS_FETCH_FROM_CTX(l->thread_ctx);
 
 	/* Call user function having proto:
-	 * void cb (resource $listener, mixed $data); */
+	 * void cb (EventListener $listener, mixed $data); */
 
 	if (ZEND_FCI_INITIALIZED(*pfci)) {
 		args[0] = &l->self;
  * target parameter may be string, socket resource, or a stream associated with a socket.
  * In case if target is a string, the string will be parsed as network address.
  *
- * Returns resource representing the event connection listener.
+ * Returns object representing the event connection listener.
  */
 PHP_METHOD(EventListener, __construct)
 {

examples/http.php

 	echo "OK\n";
 }
 
+function _http_400($req) {
+	$req->sendError(400);
+}
+
 $port = 8010;
 if ($argc > 1) {
 	$port = (int) $argv[1];
 
 $http->setCallback("/dump", "_http_dump", array(4, 8));
 $http->setCallback("/about", "_http_about");
+$http->setCallback("/err400", "_http_400");
 $http->setDefaultCallback("_http_default", "custom data value");
 
 $http->bind("0.0.0.0", 8010);
 	ZEND_ARG_INFO(0, data)
 ZEND_END_ARG_INFO();
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_event_http_req_send_error, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_http_req_send_error, 0, 0, 1)
 	ZEND_ARG_INFO(0, error)
 	ZEND_ARG_INFO(0, reason)
 ZEND_END_ARG_INFO();
 	ZEND_ARG_INFO(0, data)
 	ZEND_ARG_INFO(0, flags)
 	ZEND_ARG_INFO(0, backlog)
-	ZEND_ARG_INFO(0, stream)
+	ZEND_ARG_INFO(0, target)
 ZEND_END_ARG_INFO();
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_evconnlistener_new_bind, 0, 0, 5)