It's probably worth putting in a request.isSecure() to check if it should he http or https as then this can go back to Sakai.