def get_url(self): """Get the absolute URL of the service. Cannot be used before startService is called. This method exists primarily for testing purposes.""" port_num = self.__http_port_obj.socket.getsockname()[1] # TODO touching implementation, report need for a better way (web_port_obj.port is 0 if specified port is 0, not actual port) # TODO: need to know canonical domain name (strport_to_url defaults to localhost); can we extract the information from the certificate when applicable? return strport_to_url(self.__http_port, socket_port=port_num, path=self.get_host_relative_url())
def make_websocket_url(self, request, path): return strport_to_url(self.__ws_endpoint, hostname=request.getRequestHostname(), scheme='ws', path=path)