def get_url(self, environ):
        """Return the base URL."""
        if self.override_url:
            url = self.override_url
        else:
            # PEP333: wsgi.url_scheme, HTTP_HOST, SERVER_NAME, and SERVER_PORT
            # can be used to reconstruct a request's complete URL

            # Much of the following is copied from bottle.py
            http = (environ.get('HTTP_X_FORWARDED_PROTO') or
                    environ.get('wsgi.url_scheme', 'http'))
            host = (environ.get('HTTP_X_FORWARDED_HOST') or
                    environ.get('HTTP_HOST'))
            if not host:
                # HTTP 1.1 requires a Host-header. This is for HTTP/1.0
                # clients.
                host = environ.get('SERVER_NAME', '127.0.0.1')
                port = environ.get('SERVER_PORT')
                if port and port != ('80' if http == 'http' else '443'):
                    host += ':' + port
            url = "%s://%s" % (http, host)
        return url