| | 16 | |
|---|
| | 17 | def guess_abs_path(self): |
|---|
| | 18 | """Guess the absolute URL from server.socket_host and script_name. |
|---|
| | 19 | |
|---|
| | 20 | When inside a request, the abs_path can be formed via: |
|---|
| | 21 | cherrypy.request.base + (cherrypy.request.app.script_name or "/") |
|---|
| | 22 | |
|---|
| | 23 | However, outside of the request we must guess, hoping the deployer |
|---|
| | 24 | set socket_host and socket_port correctly. |
|---|
| | 25 | """ |
|---|
| | 26 | port = int(config.get('server.socket_port', 80)) |
|---|
| | 27 | if port in (443, 8443): |
|---|
| | 28 | scheme = "https://" |
|---|
| | 29 | else: |
|---|
| | 30 | scheme = "http://" |
|---|
| | 31 | host = config.get('server.socket_host', '') |
|---|
| | 32 | if port != 80: |
|---|
| | 33 | host += ":%s" % port |
|---|
| | 34 | return scheme + host + self.script_name |
|---|