Closed incognico closed 3 years ago
Adding the header explicitly doesn't fix the issue :( Seems like Mojo::UserAgent is stripping it out regardless.
On the plus side, sending a single character in the body to get a Content-Length of 1 works and Discord accepts it.
I think the ultimate fix here is for Discord to only require Content-Length when it is >= 1
Not sure if Discord can change the requirement of Content-Length
, it is probably a Cloudflare thing. Removing it when explicitly setting it does not sound good either, I'll open a Mojo issue then.
Fixed in https://github.com/mojolicious/mojo/issues/1738 so probably no action needed here, leaving the issue open until a new Mojo release is out and I can confirm that it works again,
Great news. Thanks for doing that!
Fixed (and confirmed) in Mojo::UserAgent 9.11, so the workaround is needed for Mojo::UserAgent versions < 9.11 and >= 9.07. Maybe add a condition to enable the workaround if any of the affected version is used, giving there is an easy way to check the mojo version.
77b97a1ad145cf45599c36ec756c30cb45614fc0 Could be made conditional with something like:
use version;
require Mojolicious;
my $mojobroken;
$mojobroken = 1 if ( version->parse( $Mojolicious::VERSION ) >= version->parse( 9.07 ) && version->parse( $Mojolicious::VERSION ) < version->parse( 9.11 ) );
I'll probably just put it in the cpanfile to be incompatible with those versions.
I'm going to just leave the workaround in place. Sending a single character doesn't (currently) break Mojo::UserAgent. I can always revisit this if that changes.
From the Mojo changelog:
This breaks most functions relying on
POST
orPUT
without a payload likestart_typing()
orcreate_reaction()
because the discord cloudflare endpoint does not like a missingContent-Length
:The
Content-Length: 0
header needs to be added back explicitly in Mojo-Discord for empty POST/PUT requests.