diff --git a/docs/news/29082019.doc b/docs/news/29082019.doc new file mode 100644 index 00000000..1cb4ae8d --- /dev/null +++ b/docs/news/29082019.doc @@ -0,0 +1 @@ +Fix webhook_grok example: avoid blocking when reading data from request stream \ No newline at end of file diff --git a/examples/connect/webhook_ngrok.py b/examples/connect/webhook_ngrok.py index ea129734..0d950eef 100644 --- a/examples/connect/webhook_ngrok.py +++ b/examples/connect/webhook_ngrok.py @@ -115,7 +115,7 @@ def webhook_handler(request): Passes the raw http body directly to mbed sdk, to notify that a webhook was received """ - body = request.stream.read().decode('utf8') + body = request.stream.read(request.content_length or 0).decode('utf8') print('webhook handler saw:', body) api.notify_webhook_received(payload=body)