diff options
| author | eltrac <hi@eltr.ac> | 2026-03-16 16:09:09 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-03-16 16:09:09 +0800 |
| commit | 5167f8d68223d4358012a2b26ebfb2fbc718839c (patch) | |
| tree | 26b44adfc9f82a956f88a767e1e23e81737d4339 /src | |
| parent | cfb53cecf2d3548cc5824ddb001e431518cbf216 (diff) | |
perf: only get first 1MB of content when verifying mention
according to
https://www.w3.org/TR/webmention/#limits-on-get-requests-p-4:~:text=Receivers%20should%20place%20limits%20on%20the%20amount,JSON%20page%20will%20be%20smaller%20than%20that.
Diffstat (limited to 'src')
| -rw-r--r-- | src/weepinbell/processor.clj | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/weepinbell/processor.clj b/src/weepinbell/processor.clj index db66d6a..a4b85a8 100644 --- a/src/weepinbell/processor.clj +++ b/src/weepinbell/processor.clj @@ -14,8 +14,10 @@ [source target] (try (timbre/info (str "Verifying mention from: " source)) - (let [{:keys [status body]} (client/get source {:throw false})] - (if (= 200 status) + ;; get first 1MB of source URL and verify + (let [{:keys [status body]} (client/get source {:throw false + :headers {"Range" "bytes=0-1048575"}})] + (if (and (>= status 200) (< status 300)) ;; TODO needs to be more robust (if (includes? (str body) target) true |
