Skip to content

Commit b429641

Browse files
hermitdemschoenenlebendjc
authored andcommitted
Expand relative URLs from Location headers (fixes #287)
1 parent 30b9890 commit b429641

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

couchdb/http.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,14 @@ def _try_request():
349349
if num_redirects > self.max_redirects:
350350
raise RedirectLimit('Redirection limit exceeded')
351351
location = resp.getheader('location')
352+
353+
# in case of relative location: add scheme and host to the location
354+
location_split = util.urlsplit(location)
355+
356+
if not location_split[0]:
357+
orig_url_split = util.urlsplit(url)
358+
location = util.urlunsplit(orig_url_split[:2] + location_split[2:])
359+
352360
if status == 301:
353361
self.perm_redirects[url] = location
354362
elif status == 303:

0 commit comments

Comments
 (0)