Merge heads
This commit is contained in:
commit
525c0ce8f4
|
@ -678,7 +678,7 @@ class HandlerTests(unittest.TestCase):
|
||||||
self.assertEqual(int(headers["Content-length"]), len(data))
|
self.assertEqual(int(headers["Content-length"]), len(data))
|
||||||
|
|
||||||
def test_file(self):
|
def test_file(self):
|
||||||
import email.utils, socket
|
import email.utils
|
||||||
h = urllib.request.FileHandler()
|
h = urllib.request.FileHandler()
|
||||||
o = h.parent = MockOpener()
|
o = h.parent = MockOpener()
|
||||||
|
|
||||||
|
@ -725,6 +725,7 @@ class HandlerTests(unittest.TestCase):
|
||||||
for url in [
|
for url in [
|
||||||
"file://localhost:80%s" % urlpath,
|
"file://localhost:80%s" % urlpath,
|
||||||
"file:///file_does_not_exist.txt",
|
"file:///file_does_not_exist.txt",
|
||||||
|
"file://not-a-local-host.com//dir/file.txt",
|
||||||
"file://%s:80%s/%s" % (socket.gethostbyname('localhost'),
|
"file://%s:80%s/%s" % (socket.gethostbyname('localhost'),
|
||||||
os.getcwd(), TESTFN),
|
os.getcwd(), TESTFN),
|
||||||
"file://somerandomhost.ontheinternet.com%s/%s" %
|
"file://somerandomhost.ontheinternet.com%s/%s" %
|
||||||
|
|
|
@ -1315,7 +1315,7 @@ class FileHandler(BaseHandler):
|
||||||
url = req.selector
|
url = req.selector
|
||||||
if url[:2] == '//' and url[2:3] != '/' and (req.host and
|
if url[:2] == '//' and url[2:3] != '/' and (req.host and
|
||||||
req.host != 'localhost'):
|
req.host != 'localhost'):
|
||||||
if not req.host is self.get_names():
|
if not req.host in self.get_names():
|
||||||
raise URLError("file:// scheme is supported only on localhost")
|
raise URLError("file:// scheme is supported only on localhost")
|
||||||
else:
|
else:
|
||||||
return self.open_local_file(req)
|
return self.open_local_file(req)
|
||||||
|
|
Loading…
Reference in New Issue