summaryrefslogtreecommitdiffstats
path: root/Lib/BaseHTTPServer.py
diff options
context:
space:
mode:
authorPeter Schneider-Kamp <nowonder@nowonder.de>2000-08-16 20:30:21 (GMT)
committerPeter Schneider-Kamp <nowonder@nowonder.de>2000-08-16 20:30:21 (GMT)
commit2d2785aad1ad7e7ea565a58187b2d1a0efa0ea54 (patch)
tree780c831d42641790e801131d8d0ac706836487c6 /Lib/BaseHTTPServer.py
parent77c9f50422833829fe1c001831f778e4fcd512df (diff)
downloadcpython-2d2785aad1ad7e7ea565a58187b2d1a0efa0ea54.zip
cpython-2d2785aad1ad7e7ea565a58187b2d1a0efa0ea54.tar.gz
cpython-2d2785aad1ad7e7ea565a58187b2d1a0efa0ea54.tar.bz2
updated occurences of fqdn algorithm (closes patch #101197)
Diffstat (limited to 'Lib/BaseHTTPServer.py')
-rw-r--r--Lib/BaseHTTPServer.py26
1 files changed, 3 insertions, 23 deletions
diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py
index ea5095a..49f8984 100644
--- a/Lib/BaseHTTPServer.py
+++ b/Lib/BaseHTTPServer.py
@@ -93,19 +93,7 @@ class HTTPServer(SocketServer.TCPServer):
"""Override server_bind to store the server name."""
SocketServer.TCPServer.server_bind(self)
host, port = self.socket.getsockname()
- if not host or host == '0.0.0.0':
- host = socket.gethostname()
- try:
- hostname, hostnames, hostaddrs = socket.gethostbyaddr(host)
- except socket.error:
- hostname = host
- else:
- if '.' not in hostname:
- for host in hostnames:
- if '.' in host:
- hostname = host
- break
- self.server_name = hostname
+ self.server_name = socket.getfqdn(host)
self.server_port = port
@@ -418,16 +406,8 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
"""
- (host, port) = self.client_address
- try:
- name, names, addresses = socket.gethostbyaddr(host)
- except socket.error, msg:
- return host
- names.insert(0, name)
- for name in names:
- if '.' in name: return name
- return names[0]
-
+ host, port = self.client_address
+ return socket.getfqdn(host)
# Essentially static class variables