From ec7deded1306169ee8f792aa80823115817c4930 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 11 Oct 2023 11:38:35 +0200 Subject: [PATCH] Restrict `is(redirect|error)` to integers (#1117) I used `isredirect` on a `HTTP.Stream` and instead of getting a `MethodError` this returned `false`. This patch limits the input to `isredirect` and `iserror` to `Integer`s. --- src/Messages.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Messages.jl b/src/Messages.jl index 51ad50bcb..bc61d10e9 100644 --- a/src/Messages.jl +++ b/src/Messages.jl @@ -235,8 +235,8 @@ issafe(method) = method in ["GET", "HEAD", "OPTIONS", "TRACE"] Does this `Response` have an error status? """ iserror(r::Response) = iserror(r.status) -iserror(status) = status != 0 && status != 100 && status != 101 && - (status < 200 || status >= 300) && !isredirect(status) +iserror(status::Integer) = status != 0 && status != 100 && status != 101 && + (status < 200 || status >= 300) && !isredirect(status) """ isredirect(::Response) @@ -245,7 +245,7 @@ Does this `Response` have a redirect status? """ isredirect(r::Response) = isredirect(r.status) isredirect(r::Request) = allow_redirects(r) && !redirectlimitreached(r) -isredirect(status) = status in (301, 302, 303, 307, 308) +isredirect(status::Integer) = status in (301, 302, 303, 307, 308) # whether the redirect limit has been reached for a given request # set in the RedirectRequest layer once the limit is reached