Skip to content

Commit ec7dede

Browse files
authored
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.
1 parent 352bca2 commit ec7dede

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Messages.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ issafe(method) = method in ["GET", "HEAD", "OPTIONS", "TRACE"]
235235
Does this `Response` have an error status?
236236
"""
237237
iserror(r::Response) = iserror(r.status)
238-
iserror(status) = status != 0 && status != 100 && status != 101 &&
239-
(status < 200 || status >= 300) && !isredirect(status)
238+
iserror(status::Integer) = status != 0 && status != 100 && status != 101 &&
239+
(status < 200 || status >= 300) && !isredirect(status)
240240

241241
"""
242242
isredirect(::Response)
@@ -245,7 +245,7 @@ Does this `Response` have a redirect status?
245245
"""
246246
isredirect(r::Response) = isredirect(r.status)
247247
isredirect(r::Request) = allow_redirects(r) && !redirectlimitreached(r)
248-
isredirect(status) = status in (301, 302, 303, 307, 308)
248+
isredirect(status::Integer) = status in (301, 302, 303, 307, 308)
249249

250250
# whether the redirect limit has been reached for a given request
251251
# set in the RedirectRequest layer once the limit is reached

0 commit comments

Comments
 (0)