lib/net/dav.rb in net_dav-0.3.0 vs lib/net/dav.rb in net_dav-0.3.1
- old
+ new
@@ -127,11 +127,12 @@
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
response = nil
if block
@http.request(req) {|res|
- res.read_body nil, &block
+ # Only start returning a body if we will not retry
+ res.read_body nil, &block if !res.is_a?(Net::HTTPUnauthorized) && !res.is_a?(Net::HTTPRedirection)
response = res
}
else
response = @http.request(req)
end
@@ -154,10 +155,10 @@
when Net::HTTPRedirection then
location = URI.parse(response['location'])
if (@uri.scheme != location.scheme ||
@uri.host != location.host ||
@uri.port != location.port)
- raise "cannot redirect to a different host #{@uri} => #{location}"
+ raise ArgumentError, "cannot redirect to a different host #{@uri} => #{location}"
end
new_req = clone_req(location.path, req, headers)
return handle_request(new_req, headers, limit - 1, &block)
else
response.error!