Skip to content

Commit

Permalink
let the client handle the redirect, don't do it internally
Browse files Browse the repository at this point in the history
Say a user wants to get http://www.example.com/protected/ and that if
this service wasn't behind twitcher, the user would get redirected to
http://www.example.com/protected/other/
Now if this service is behind twitcher, twitcher follows redirects
internally and returns http://www.example.com/protected/other/ to
the user. Now the user's url location is still
http://www.example.com/protected/ but the content is
http://www.example.com/protected/other/
If the protected web server generates relative urls in its content or
redirects, these urls are then broken.
  • Loading branch information
davidcaron committed Sep 17, 2019
1 parent bd2f965 commit 6e8203a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions twitcher/owsproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ def _send_request(request, service, extra_path=None, request_params=None):
url = service['url']
if extra_path:
url += '/' + extra_path
elif request.url.endswith('/'):
url += '/'
if request_params:
url += '?' + request_params
LOGGER.debug('url = %s', url)

# forward request to target (without Host Header)
h = dict(request.headers)
h.pop("Host", h)
h['Accept-Encoding'] = None
#
service_type = service['type']
if service_type and (service_type.lower() != 'wps'):
try:
resp_iter = requests.request(method=request.method.upper(), url=url, data=request.body, headers=h,
stream=True, verify=service.verify)
stream=True, verify=service.verify, allow_redirects=False)
except Exception as e:
return OWSAccessFailed("Request failed: {}".format(e))

Expand Down

0 comments on commit 6e8203a

Please sign in to comment.