Tiny Tiny RSS: Community

Patch: Fix retry for gzip-broken servers

Since the whole flow for long-time-lurkers first-time-contributors is just broken, here’s a patch directly.

Author: SirBacon <[email protected]>
Date:   Wed Apr 10 18:31:28 2019 -0700

    fetch_file_contents: Fix retry
    Detect a failed curl_exec immediately, and possibly attempt a
    retry with a forced encoding identity encoding.
    This fixes incorrectly attempting to parse false as a string,
    as well as the retry filling $contents with the complete reply
    including headers (without splitting off and parsing the headers).

diff --git a/include/functions.php b/include/functions.php
index c09e62cca..a66474d13 100755
--- a/include/functions.php
+++ b/include/functions.php
@@ -386,6 +386,20 @@
                                curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass");
                        $ret = @curl_exec($ch);
+                       if ($ret === false) {
+                               // Possibly a gzip issue makes curl unhappy.
+                               if (curl_errno($ch) === 23 || curl_errno($ch) === 61) {
+                                       // Docs say 'identity,' but 'none' seems to work.
+                                       curl_setopt($ch, CURLOPT_ENCODING, 'none');
+                                       $ret = @curl_exec($ch);
+                                       if ($ret === false) {
+                                               // Give up.
+                                               $fetch_last_error = curl_errno($ch) . " " . curl_error($ch);
+                                               curl_close($ch);
+                                               return false;
+                                       }
+                               }
+                       }
                        $headers_length = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
                        $headers = explode("\r\n", substr($ret, 0, $headers_length));
@@ -406,11 +420,6 @@
-                       if (curl_errno($ch) === 23 || curl_errno($ch) === 61) {
-                               curl_setopt($ch, CURLOPT_ENCODING, 'none');
-                               $contents = @curl_exec($ch);
-                       }
                        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                        $fetch_last_content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);

its only broken if you think that slight inconvenience of registering on Gogs and sending 1 (one) PM is too much effort – as opposed to me allowing open forking and cleaning up Gogs spam all the time, just because, occasionally, some fickle fuckwit might enlighten me with a pull request.

if you don’t value my time, i’m not interested in your contributions. take your diff and fuck off off my forum.

I mean for sure I am the fuckwit because I’m fixing your braindead code. And for sure I’m the fuckwit who can’t pm you because as a newbie I have no fucking permissions to do so. But sure, oh glorious leader fox, you’re always right…

somehow other people manage to deal with this. and it’s not like you even have to PM, posting your gogs username in the thread would’ve worked just as well. we’re not that much of a bureaucracy here.

just because tt-rss doesn’t invoke curl fifty times or whatever because of some broken server doesn’t mean the code is brainded.

there’s some amount of workarounds for broken servers that may be allowed, i suppose, but at some point person on the other end might as well fix their shit already.

in any case, going by your username, maybe reddit would be a better fit for you. consider posting there from now on.

Was it really that hard to read the pinned topic?

And if you’re a longtime lurker, you should know how it’s done. Here’s an example; it’s not difficult.

That’s bullshit and you know it. The existing “workaround” simply doesn’t work, period. It makes the code actively worse.

So go ahead and say “we shouldn’t need workarounds,” and I can agree with that (wish I didn’t want to read a certain feed), but obviously you’re contradicting yourself with your own code.

Was it really that hard to read my reply? I cannot follow those instructions.

Yeah, fuck me for not going with a couple of “Hi I am …” idiot posts to get my “trust level” up. Or to have the gall to point out that the official flow is broken and that I have to post a diff as a topic in a fucking discourse topic. And for not crawling up fox’s ass.

as i’ve already posted above, you could’ve just mentioned your gogs username along with your diff, instead of going on this pointless autistic crusade.

i can’t tell how relevant this workaround is now but if it “didn’t work, period” it’s unlikely that it would be added in the first place. maybe it should be removed.

anyway, i’m definitely not interested in discussing this with you, personally. :face_with_raised_eyebrow:

e: moving this to where it belongs because i see zero potential of this thread being productive.