From 561130a802fdbfb1491e2981dc9367ce5597b63d Mon Sep 17 00:00:00 2001 From: Ruslaideemin Date: Mon, 10 Jun 2013 19:34:52 +1000 Subject: [PATCH] Support relative redirects One particular WebDAV software has generated a relative redirect, which is not currently supported. Support it by setting the scheme, host, and port to the existing @uri if they are nil. --- lib/net/dav.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/net/dav.rb b/lib/net/dav.rb index ea29d63..2fe2731 100644 --- a/lib/net/dav.rb +++ b/lib/net/dav.rb @@ -190,6 +190,12 @@ def handle_request(req, headers, limit = MAX_REDIRECTS, &block) return handle_request(req, headers, limit - 1, &block) when Net::HTTPRedirection then location = URI.parse(response['location']) + + # Support relative redirects, where they are of the format of /blah/ + location.scheme ||= @uri.scheme + location.host ||= @uri.host + location.port ||= @uri.port + if (@uri.scheme != location.scheme || @uri.host != location.host || @uri.port != location.port)