Closed kingo55 closed 2 years ago
Kodi incorrectly uses MHD API.
MHD automatically sets "Content-Length" header when needed (and allowed by RFC).
Flag MHD_RF_INSANITY_HEADER_CONTENT_LENGTH
breaks standard processing and should not be used unless application wants to produce non-standard response not compatible with RFC specifications.
PR with fix for Kodi: https://github.com/xbmc/xbmc/pull/21019
Thanks for the API fix on Kodi, @Karlson2k! Really appreciate it - MHD is the glue between Home Assistant and Kodi.
Just saved potentially a few thousand Home Assistant / Kodi users' smart homes from breaking.
@kingo55 Feel free to contract me directly by mail or in MHD mailing list for any MHD-related issues.
Expected behaviour
If the response headers contain a
Content-Length
header then MHD doesn't add one.Actual behaviour
When a response already contains a
Content-Length
header, MHD adds another one, causing some useragents to reject the response.For example, when a non-compliant duplicate header exists, Python's
aiohttp
library, for example, raises an exception:Further details
I discovered this behaviour downstream in XBMC which uses a MHD version
0x00097500
- details here: https://github.com/xbmc/xbmc/issues/20759We think it may be due to this commit https://github.com/Karlson2k/libmicrohttpd/commit/4820d93bc91eea924dcad29e879f31d8d28649a1.
As the resolution to this issue is external to Kodi, I thought I should raise this in the correct upstream repo.