Skip to content

Commit 0bb3e0a

Browse files
committed
Dead Link Checker: allow 403 for Reddit
Cannot find any other reliable solution.
1 parent 9fa33c3 commit 0bb3e0a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

scripts/check-dead-links.fsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ let collectLinks node =
3939

4040
let exclusionCodes = Map.ofArray [|
4141
"https://www.lkokemohr.de/fsharp_godot.html", HttpStatusCode.TooManyRequests // GitHub runner receives this often
42-
|]
43-
let userAgents = Map.ofArray [|
44-
// Reddit doesn't like when we access it without any user-agent header.
45-
// Note that this won't work for every other resource; e.g., X doesn't like whe we *pass* the user-agent.
46-
"https://www.reddit.com/r/fsharp/", "Mozilla/5.0 (compatible; +https://github.com/fsprojects/awesome-fsharp)"
42+
"https://www.reddit.com/r/fsharp/", HttpStatusCode.Forbidden
4743
|]
4844

4945
let printLock = Object()
@@ -55,13 +51,7 @@ let checkLinkStatus (client: HttpClient) (url: string) = task {
5551
try
5652
lock printLock (fun () -> printfn $"Verifying link {url}…")
5753
let! response = retryPipeline.ExecuteAsync(
58-
fun _ -> ValueTask<HttpResponseMessage>(task {
59-
use request = new HttpRequestMessage(HttpMethod.Get, url)
60-
Map.tryFind url userAgents |> Option.iter(
61-
fun ua -> request.Headers.TryAddWithoutValidation("User-Agent", ua) |> ignore
62-
)
63-
return! client.SendAsync request
64-
})
54+
fun _ -> ValueTask<HttpResponseMessage>(client.GetAsync url)
6555
)
6656
if response.StatusCode <> HttpStatusCode.OK then
6757
return

0 commit comments

Comments
 (0)