From c7b304ef20880c7808b1748c19907e830d1e0b0d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 6 Nov 2023 02:08:51 -0700 Subject: [PATCH] Update http client --- app/Jobs/InboxPipeline/InboxValidator.php | 2 +- app/Jobs/InboxPipeline/InboxWorker.php | 2 +- app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.php | 2 +- app/Services/ActivityPubFetchService.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Jobs/InboxPipeline/InboxValidator.php b/app/Jobs/InboxPipeline/InboxValidator.php index 4017d3ac..8d0f414c 100644 --- a/app/Jobs/InboxPipeline/InboxValidator.php +++ b/app/Jobs/InboxPipeline/InboxValidator.php @@ -193,7 +193,7 @@ class InboxValidator implements ShouldQueue } try { - $res = Http::timeout(20)->withHeaders([ + $res = Http::withOptions(['allow_redirects' => false])->timeout(20)->withHeaders([ 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'User-Agent' => 'PixelfedBot v0.1 - https://pixelfed.org', ])->get($actor->remote_url); diff --git a/app/Jobs/InboxPipeline/InboxWorker.php b/app/Jobs/InboxPipeline/InboxWorker.php index c8508c0f..1bc88507 100644 --- a/app/Jobs/InboxPipeline/InboxWorker.php +++ b/app/Jobs/InboxPipeline/InboxWorker.php @@ -173,7 +173,7 @@ class InboxWorker implements ShouldQueue } try { - $res = Http::timeout(20)->withHeaders([ + $res = Http::withOptions(['allow_redirects' => false])->timeout(20)->withHeaders([ 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'User-Agent' => 'PixelfedBot v0.1 - https://pixelfed.org', ])->get($actor->remote_url); diff --git a/app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.php b/app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.php index 6cb11ddc..23b8716c 100644 --- a/app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.php +++ b/app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.php @@ -90,7 +90,7 @@ class StatusRemoteUpdatePipeline implements ShouldQueue ]); $nm->each(function($n, $key) use($status) { - $res = Http::retry(3, 100, throw: false)->head($n['url']); + $res = Http::withOptions(['allow_redirects' => false])->retry(3, 100, throw: false)->head($n['url']); if(!$res->successful()) { return; diff --git a/app/Services/ActivityPubFetchService.php b/app/Services/ActivityPubFetchService.php index 3d1980a1..cbf153ec 100644 --- a/app/Services/ActivityPubFetchService.php +++ b/app/Services/ActivityPubFetchService.php @@ -28,7 +28,7 @@ class ActivityPubFetchService $headers['User-Agent'] = 'PixelFedBot/1.0.0 (Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')'; try { - $res = Http::withHeaders($headers) + $res = Http::withOptions(['allow_redirects' => false])->withHeaders($headers) ->timeout(30) ->connectTimeout(5) ->retry(3, 500)