Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Missing trailing slash on inet_http_server redirects #669

Merged
merged 1 commit into from
Oct 10, 2017

Conversation

lukeweber
Copy link
Contributor

Fixes #640 - get_server_url() strips the trailing "/", so it has to be added back on the redirect between the host and http args.

http.py

    def get_server_url(self):
        """ Functionality that medusa's http request doesn't have; set an
        attribute named 'server_url' on the request based on the Host: header
        """
        default_port={'http': '80', 'https': '443'}
        environ = self.cgi_environment()
        if (environ.get('HTTPS') in ('on', 'ON') or
            environ.get('SERVER_PORT_SECURE') == "1"):
            # XXX this will currently never be true
            protocol = 'https'
        else:
            protocol = 'http'

        if 'HTTP_HOST' in environ:
            host = environ['HTTP_HOST'].strip()
            hostname, port = urllib.splitport(host)
        else:
            hostname = environ['SERVER_NAME'].strip()
            port = environ['SERVER_PORT']

        if port is None or default_port[protocol] == port:
            host = hostname
        else:
            host = hostname + ':' + port
        server_url = '%s://%s' % (protocol, host)
        if server_url[-1:]=='/':
            server_url=server_url[:-1]
        return server_url

@lukeweber lukeweber changed the title Fix for Missing trailing slash on inet_http_server redirects - #640 Fix for Missing trailing slash on inet_http_server redirects Oct 7, 2015
@mnaberez
Copy link
Member

@rafis @lukeweber @calvin Could you guys please review this against #593?

That pull request is another attempt at better proxy support that also makes the URL more configurable. If #593 also fixes this issue maybe we should just merge that. I'm not using the web interface behind a proxy server so I appreciate your feedback.

@calvin
Copy link

calvin commented Oct 11, 2015

#593 fixes this by introducing new base_path setting. Also it ensures the trailing / always exists. (https://github.com/Supervisor/supervisor/pull/593/files#diff-0240b66c1a20db854f3d6eacb71caa32R1031)

@mnaberez mnaberez added the web label Oct 22, 2015
@mnaberez mnaberez merged commit c6922a5 into Supervisor:master Oct 10, 2017
mnaberez added a commit that referenced this pull request Feb 8, 2018
Fix for Missing trailing slash on inet_http_server redirects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants