# A few changes to Feedparse's HTTP requester (prelude to Feedbot)

089 March 19, 2019 -- (tech tmsr)

This post introduces s-xml-feedparse-http-fixes:

So what do these changes slash "HTTP fixes" consist of, more precisely? Two pieces of code are being repaired -- one of the repairs being required by Feedbot, while the other is more or less an opportunity for making the code a tad clea[nr]er. The latter (simpler) one goes as follows:

+(defvar *http-request-timeout* 60)

...

-  (parse-feed-string (http-request-with-timeout url 60)))
+  (parse-feed-string (http-request-with-timeout url *http-request-timeout*)))

In other words, we're calling http-request-with-timeout with an operator-configurable timeout setting -- as it should have been in the first place, but let's not go into too many details, lest I end up burning myself and applying ice on the wound.

The former (more important) change is along the lines of:

+(defun http-request-thread (url timeout)
+  (handler-case
+      (drakma:http-request url :connection-timeout timeout)
+    ;; Note: this will have to be revisited once we have a sane view of
+    ;; all the conditions returned by drakma.
+    (t (c)
+      (return-from http-request-thread (values nil c)))))

... and a bit later:

+             #'http-request-thread
This means that the thread we're creating now runs the code in http-request-thread instead of an anonymous function; but more importantly, that the call to Drakma's http-request is now guarded by a handler-case that, long story short, acts as a wildcard exception catcher.