http-useragent
http-useragent copied to clipboard
Respect :throw-exceptions flag in case of exceeding max redirects limit
in case of 4xx 5xx errors you don't throw any exceptions and just return response as is
if $!throw-exceptions {
given $response.code {
when /^4/ {
X::HTTP::Response.new(:rc($response.status-line), :response($response)).throw;
}
when /^5/ {
X::HTTP::Server.new(:rc($response.status-line), :response($response)).throw;
}
}
}
but in case of to many 302 redirects you don't check this flag
if $.max-redirects < $.redirects-in-a-row {
X::HTTP::Response.new(:rc('Max redirects exceeded'), :response($response)).throw;
}
in my case I don't want to do any redirect at all, just get the first result. But setting max-redirects to zero doesn't help.