summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/ConnectionInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'py/modules/IcePy/ConnectionInfo.cpp')
-rw-r--r--py/modules/IcePy/ConnectionInfo.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/py/modules/IcePy/ConnectionInfo.cpp b/py/modules/IcePy/ConnectionInfo.cpp
index 583885382e4..d8c34789b63 100644
--- a/py/modules/IcePy/ConnectionInfo.cpp
+++ b/py/modules/IcePy/ConnectionInfo.cpp
@@ -135,6 +135,32 @@ udpConnectionInfoGetMcastPort(ConnectionInfoObject* self, void* member)
return PyLong_FromLong(info->mcastPort);
}
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+wsConnectionInfoGetHeaders(ConnectionInfoObject* self)
+{
+ Ice::WSConnectionInfoPtr info = Ice::WSConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ assert(info);
+
+ PyObjectHandle result = PyDict_New();
+ if(result.get())
+ {
+ for(Ice::HeaderDict::iterator p = info->headers.begin(); p != info->headers.end(); ++p)
+ {
+ PyObjectHandle key = createString(p->first);
+ PyObjectHandle val = createString(p->second);
+ if(!val.get() || PyDict_SetItem(result.get(), key.get(), val.get()) < 0)
+ {
+ return 0;
+ }
+ }
+ }
+
+ return result.release();
+}
+
static PyGetSetDef ConnectionInfoGetters[] =
{
{ STRCAST("incoming"), reinterpret_cast<getter>(connectionInfoGetIncoming), 0,
@@ -166,6 +192,13 @@ static PyGetSetDef UDPConnectionInfoGetters[] =
{ 0, 0 } /* sentinel */
};
+static PyGetSetDef WSConnectionInfoGetters[] =
+{
+ { STRCAST("headers"), reinterpret_cast<getter>(wsConnectionInfoGetHeaders), 0,
+ PyDoc_STR(STRCAST("request headers")), 0 },
+ { 0, 0 } /* sentinel */
+};
+
namespace IcePy
{
@@ -357,6 +390,53 @@ PyTypeObject UDPConnectionInfoType =
0, /* tp_is_gc */
};
+PyTypeObject WSConnectionInfoType =
+{
+ /* The ob_type field must be initialized in the module init function
+ * to be portable to Windows without using C++. */
+ PyVarObject_HEAD_INIT(0, 0)
+ STRCAST("IcePy.WSConnectionInfo"),/* tp_name */
+ sizeof(ConnectionInfoObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)connectionInfoDealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ WSConnectionInfoGetters, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ (newfunc)connectionInfoNew, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+};
+
}
bool
@@ -405,6 +485,17 @@ IcePy::initConnectionInfo(PyObject* module)
return false;
}
+ WSConnectionInfoType.tp_base = &IPConnectionInfoType; // Force inheritance from IPConnectionType.
+ if(PyType_Ready(&WSConnectionInfoType) < 0)
+ {
+ return false;
+ }
+ type = &WSConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings.
+ if(PyModule_AddObject(module, STRCAST("WSConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0)
+ {
+ return false;
+ }
+
return true;
}
@@ -428,6 +519,10 @@ IcePy::createConnectionInfo(const Ice::ConnectionInfoPtr& connectionInfo)
{
type = &UDPConnectionInfoType;
}
+ else if(Ice::WSConnectionInfoPtr::dynamicCast(connectionInfo))
+ {
+ type = &WSConnectionInfoType;
+ }
else if(Ice::IPConnectionInfoPtr::dynamicCast(connectionInfo))
{
type = &IPConnectionInfoType;