From f624ac1fe5aa186a07d6c885e3044c8afb41a24e Mon Sep 17 00:00:00 2001 From: Ronald Steinke Date: Fri, 5 Oct 2018 11:44:56 +0200 Subject: [PATCH] fixes chunked data receiving in notification http server --- openmtc-app/src/openmtc_app/notification/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmtc-app/src/openmtc_app/notification/__init__.py b/openmtc-app/src/openmtc_app/notification/__init__.py index 6526360..f69c9fa 100644 --- a/openmtc-app/src/openmtc_app/notification/__init__.py +++ b/openmtc-app/src/openmtc_app/notification/__init__.py @@ -256,6 +256,13 @@ class HttpNotificationHandler(BaseNotificationHandler): assert 'x-m2m-ri' in request.headers, 'Missing request id' assert 'content-type' in request.headers, 'Unspecified content type' + if not request.data: + if request.environ.get('HTTP_TRANSFER_ENCODING') == 'chunked': + request.data = request.environ['wsgi.input'].read() + else: + cl = int(request.environ.get('CONTENT_LENGTH'), 0) + request.data = request.environ['wsgi.input'].read(cl) + notification = get_onem2m_decoder(request.content_type).decode(request.data) if not notification.verificationRequest: notification = self._unpack_notification(notification)