summaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
Diffstat (limited to 'php')
-rw-r--r--php/src/IcePHP/Connection.cpp32
-rw-r--r--php/test/Ice/info/Client.php22
2 files changed, 52 insertions, 2 deletions
diff --git a/php/src/IcePHP/Connection.cpp b/php/src/IcePHP/Connection.cpp
index 10f5df4488d..1847dd9124b 100644
--- a/php/src/IcePHP/Connection.cpp
+++ b/php/src/IcePHP/Connection.cpp
@@ -26,6 +26,7 @@ static zend_class_entry* connectionInfoClassEntry = 0;
static zend_class_entry* ipConnectionInfoClassEntry = 0;
static zend_class_entry* tcpConnectionInfoClassEntry = 0;
static zend_class_entry* udpConnectionInfoClassEntry = 0;
+static zend_class_entry* wsConnectionInfoClassEntry = 0;
//
// Ice::Connection support.
@@ -531,6 +532,19 @@ IcePHP::connectionInit(TSRMLS_D)
zend_declare_property_long(udpConnectionInfoClassEntry, STRCAST("mcastPort"), sizeof("mcastPort") - 1, 0,
ZEND_ACC_PUBLIC TSRMLS_CC);
+ //
+ // Register the WSConnectionInfo class.
+ //
+#ifdef ICEPHP_USE_NAMESPACES
+ INIT_NS_CLASS_ENTRY(ce, "Ice", "WSConnectionInfo", NULL);
+#else
+ INIT_CLASS_ENTRY(ce, "Ice_WSConnectionInfo", NULL);
+#endif
+ ce.create_object = handleConnectionInfoAlloc;
+ wsConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC);
+ zend_declare_property_string(wsConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1,
+ STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
+
return true;
}
@@ -592,6 +606,24 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC
add_property_long(zv, STRCAST("mcastPort"), static_cast<long>(info->mcastPort));
}
}
+ else if(Ice::WSConnectionInfoPtr::dynamicCast(p))
+ {
+ Ice::WSConnectionInfoPtr info = Ice::WSConnectionInfoPtr::dynamicCast(p);
+ if((status = object_init_ex(zv, wsConnectionInfoClassEntry)) == SUCCESS)
+ {
+ zval* zmap;
+ MAKE_STD_ZVAL(zmap);
+ AutoDestroy mapDestroyer(zmap);
+ if(createStringMap(zmap, info->headers TSRMLS_CC))
+ {
+ add_property_zval(zv, STRCAST("headers"), zmap);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
else if(Ice::IPConnectionInfoPtr::dynamicCast(p))
{
status = object_init_ex(zv, ipConnectionInfoClassEntry);
diff --git a/php/test/Ice/info/Client.php b/php/test/Ice/info/Client.php
index 46c800c3b33..1e9b275b064 100644
--- a/php/test/Ice/info/Client.php
+++ b/php/test/Ice/info/Client.php
@@ -40,6 +40,7 @@ function allTests($communicator)
$udpEndpointInfoClass = $NS ? "Ice\\UDPEndpointInfo" : "Ice_UDPEndpointInfo";
$sslEndpointType = 2;
$wsEndpointType = $NS ? constant("Ice\\WSEndpointType") : constant("Ice_WSEndpointType");
+ $wsEndpointInfoClass = $NS ? "Ice\\WSEndpointInfo" : "Ice_WSEndpointInfo";
$wssEndpointType = $NS ? constant("Ice\\WSSEndpointType") : constant("Ice_WSSEndpointType");
$protocolVersionClass = $NS ? "Ice\\ProtocolVersion" : "Ice_ProtocolVersion";
$encodingVersionClass = $NS ? "Ice\\EncodingVersion" : "Ice_EncodingVersion";
@@ -68,8 +69,8 @@ function allTests($communicator)
($ipEndpoint->type() == $wssEndpointType && $ipEndpoint->secure()));
test(($ipEndpoint->type() == $tcpEndpointType && ($ipEndpoint instanceof $tcpEndpointInfoClass)) ||
($ipEndpoint->type() == $sslEndpointType && ($ipEndpoint instanceof $ipEndpointInfoClass)) ||
- ($ipEndpoint->type() == $wsEndpointType && ($ipEndpoint instanceof $ipEndpointInfoClass)) ||
- ($ipEndpoint->type() == $wssEndpointType && ($ipEndpoint instanceof $ipEndpointInfoClass)));
+ ($ipEndpoint->type() == $wsEndpointType && ($ipEndpoint instanceof $wsEndpointInfoClass)) ||
+ ($ipEndpoint->type() == $wssEndpointType && ($ipEndpoint instanceof $wsEndpointInfoClass)));
$udpEndpoint = $endps[1]->getInfo();
test($udpEndpoint instanceof $udpEndpointInfoClass);
@@ -118,6 +119,7 @@ function allTests($communicator)
flush();
{
$ipConnectionInfoClass = $NS ? "Ice\\IPConnectionInfo" : "Ice_IPConnectionInfo";
+ $wsConnectionInfoClass = $NS ? "Ice\\WSConnectionInfo" : "Ice_WSConnectionInfo";
$info = $base->ice_getConnection()->getInfo();
test($info instanceof $ipConnectionInfoClass);
@@ -137,6 +139,22 @@ function allTests($communicator)
test($ctx["localAddress"] == $info->remoteAddress);
test($ctx["remotePort"] == $info->localPort);
test($ctx["localPort"] == $info->remotePort);
+
+ if($base->ice_getConnection()->type() == "ws" || $base->ice_getConnection()->type() == "wss")
+ {
+ test($info instanceof $wsConnectionInfoClass);
+
+ test($info->headers["Upgrade"] == "websocket");
+ test($info->headers["Connection"] == "Upgrade");
+ test($info->headers["Sec-WebSocket-Protocol"] == "ice.zeroc.com");
+ test(isset($info->headers["Sec-WebSocket-Accept"]));
+
+ test($ctx["ws.Upgrade"] == "websocket");
+ test($ctx["ws.Connection"] == "Upgrade");
+ test($ctx["ws.Sec-WebSocket-Protocol"] == "ice.zeroc.com");
+ test($ctx["ws.Sec-WebSocket-Version"] == "13");
+ test(isset($ctx["ws.Sec-WebSocket-Key"]));
+ }
}
echo "ok\n";