android_income_sms_gateway_webhook icon indicating copy to clipboard operation
android_income_sms_gateway_webhook copied to clipboard

Transfer-Encoding: Chunked causes issues with some HTTP servers

Open pmalecka opened this issue 1 year ago • 2 comments

Hi bogkonstantin,

first of all, thanks for creating this wonderful tool, I use it daily.

Recently, I have been trying to use your app with Microsoft Teams Webhook API. I found that this API and other APIs as well as some HTTP servers (Apache) have issue with Transfer-Encoding: chunked.

In my case, Microsoft's servers simply respond with: 400 Invalid webhook request - Empty Payload.

If it is not too complicated, I think a simple change could make the app compatible with even more server configs and solutions:

Removal of Transfer-Encoding: Chunked, inclusion of Content-Length header.

Footnotes: Apache issue: https://www.jeffgeerling.com/blog/2017/apache-fastcgi-proxyfcgi-and-empty-post-bodies-chunked-transfer

How to set up a webhook in Teams: https://sankalpit.com/plugins/documentation/how-to-get-channel-webhook-url/

Curl snippet that is closer to the actual request the app sends: curl -ivsS --trace --request POST 'http://testurl/path' --header 'Content-Type: application/json; charset=utf-8' -H 'Transfer-Encoding: chunked' --data '{"text":"sms text"}'

Thanks, Peter

pmalecka avatar May 30 '23 10:05 pmalecka

Update: The fix is fairly trivial, I created a PR..

pmalecka avatar May 30 '23 11:05 pmalecka

Hi ! I want to receive SMS forwarded into my Python Server with Django Framework. The POST Request is blocked with Django. The solution is to add @csrf_exempt décoration before function AND add into header (in app) content-length : 50000 (random integer) else django block request and the body is empty ! It's possible to add a checkbox for transfert-encoding to delete issus with Python/django to improve the app.

Thanks for the app with your work !

(sorry for my English, i'm French)

Litibe avatar Jun 26 '23 20:06 Litibe

Done in v.2.3.0 - see checkbox Chunked vs Fixed mode

bogkonstantin avatar Apr 28 '24 13:04 bogkonstantin