[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Duplicate Content-Length headers set by MHD & applic
From: |
Evgeny Grin |
Subject: |
Re: [libmicrohttpd] Duplicate Content-Length headers set by MHD & application |
Date: |
Sun, 20 Feb 2022 12:52:17 +0300 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 |
Hi Rob,
Kodi currently using MHD API incorrectly.
There is no need to use MHD_RF_INSANITY_HEADER_CONTENT_LENGTH unless you
are testing HTTP client with incorrect HTTP response. The flag allow
application to override MHD automatic value.
There is no need to set `Content-Length` manually. MHD always sets it
automatically, when this header is needed.
As a member of Kodi-team I'll make a PR with proper fix for Kodi. :)
--
Evgeny
On 20.02.2022 5:23, Rob Kingston wrote:
Hi there,
Kodi uses MHD for its web interface and JSON API. A recent update on MHD
has changed Content-Length headers to be set automatically without
throwing any errors or overriding the existing headers when present.
This results in the header being set twice when the application
inadvertently sets it. E.g. resulting in headers like:
HTTP/1.1 200 OK
Date: Sat, 19 Feb 2022 23:59:56 GMT
Accept-Ranges: none
Cache-Control: private, max-age=0, no-cache
Content-Length: 649
Content-Type: application/json
Content-Length: 649
Unfortunately, some useragents reject responses where this is set
multiple times. Python's aiohttp library is one such useragent that
breaks due to this.
There's discussion about handling this in Kodi by conditionally setting
the Content-Length headers depending on the version of MHD being run.
However it looks like MHD has also recently handled such cases before too:
https://github.com/Karlson2k/libmicrohttpd/commit/16ac89f3beb982dab4f1552ffb94e637b45ca324
<https://github.com/Karlson2k/libmicrohttpd/commit/16ac89f3beb982dab4f1552ffb94e637b45ca324>
What is the best way to handle this going forward?
Cheers,
Rob
OpenPGP_signature
Description: OpenPGP digital signature