faster local_hosts lookup
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.1.0 (2012-10-10 11:25:21) dev
|
Version 2.1.0 (2012-10-10 11:43:02) dev
|
||||||
|
|||||||
+13
-12
@@ -426,18 +426,19 @@ def wsgibase(environ, responder):
|
|||||||
app = request.application ## must go after url_in!
|
app = request.application ## must go after url_in!
|
||||||
|
|
||||||
http_host = env.http_host.split(':',1)[0]
|
http_host = env.http_host.split(':',1)[0]
|
||||||
local_hosts = [http_host,'::1','127.0.0.1',
|
if not global_settings.local_hosts:
|
||||||
'::ffff:127.0.0.1']
|
local_hosts = ['127.0.0.1','::ffff:127.0.0.1']
|
||||||
if not global_settings.web2py_runtime_gae:
|
if not global_settings.web2py_runtime_gae:
|
||||||
try:
|
try:
|
||||||
local_hosts.append(socket.gethostname())
|
local_hosts.append(socket.gethostname())
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
local_hosts.append(
|
local_hosts.append(socket.gethostbyname(http_host))
|
||||||
socket.gethostbyname(http_host))
|
except (socket.gaierror,TypeError):
|
||||||
except (socket.gaierror,TypeError):
|
pass
|
||||||
pass
|
global_settings.local_hosts = local_hosts
|
||||||
|
local_hosts = global_settings.local_hosts + [http_host]
|
||||||
client = get_client(env)
|
client = get_client(env)
|
||||||
x_req_with = str(env.http_x_requested_with).lower()
|
x_req_with = str(env.http_x_requested_with).lower()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,6 +6,7 @@ License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import socket
|
||||||
import platform
|
import platform
|
||||||
from storage import Storage
|
from storage import Storage
|
||||||
|
|
||||||
@@ -37,4 +38,3 @@ global_settings.is_jython = \
|
|||||||
str(sys.copyright).find('Jython') > 0
|
str(sys.copyright).find('Jython') > 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user