mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-18 10:59:45 +00:00
Changing API: callback doesnt get mg_request_info pointer anymore, but it is possible to get it using mg_get_request_info()
This commit is contained in:
1 parent
e8f3132aa8
commit
0e0091e1c0
6 files changed
+24
-17
No files matched your search
@@ -73,10 +73,7 @@ class mg_request_info(ctypes.Structure):
|
||||
]
|
||||
|
||||
|
||||
mg_callback_t = ctypes.CFUNCTYPE(ctypes.c_void_p,
|
||||
ctypes.c_int,
|
||||
ctypes.c_void_p,
|
||||
ctypes.POINTER(mg_request_info))
|
||||
mg_callback_t = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p)
|
||||
|
||||
|
||||
class Connection(object):
|
||||
@@ -86,6 +83,7 @@ class Connection(object):
|
||||
def __init__(self, mongoose, connection):
|
||||
self.m = mongoose
|
||||
self.conn = ctypes.c_void_p(connection)
|
||||
self.info = self.m.dll.mg_get_request_info(self.conn).contents
|
||||
|
||||
def get_header(self, name):
|
||||
val = self.m.dll.mg_get_header(self.conn, name)
|
||||
@@ -132,14 +130,15 @@ class Mongoose(object):
|
||||
self.dll.mg_get_var.restype = ctypes.c_int
|
||||
self.dll.mg_get_cookie.restype = ctypes.c_int
|
||||
self.dll.mg_get_option.restype = ctypes.c_char_p
|
||||
self.dll.mg_get_request_info.restype = ctypes.POINTER(mg_request_info)
|
||||
|
||||
if callback:
|
||||
# Create a closure that will be called by the shared library.
|
||||
def func(event, connection, request_info):
|
||||
def func(event, connection):
|
||||
# Wrap connection pointer into the connection
|
||||
# object and call Python callback
|
||||
conn = Connection(self, connection)
|
||||
return callback(event, conn, request_info.contents) and 1 or 0
|
||||
return callback(event, conn) and 1 or 0
|
||||
|
||||
# Convert the closure into C callable object
|
||||
self.callback = mg_callback_t(func)
|
||||
|
||||
Reference in new issue
Block a user