File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -1276,22 +1276,25 @@ def open_local_file(self, req):
1276
1276
import email .utils
1277
1277
import mimetypes
1278
1278
host = req .get_host ()
1279
- file = req .get_selector ()
1280
- localfile = url2pathname (file )
1279
+ filename = req .get_selector ()
1280
+ localfile = url2pathname (filename )
1281
1281
try :
1282
1282
stats = os .stat (localfile )
1283
1283
size = stats .st_size
1284
1284
modified = email .utils .formatdate (stats .st_mtime , usegmt = True )
1285
- mtype = mimetypes .guess_type (file )[0 ]
1285
+ mtype = mimetypes .guess_type (filename )[0 ]
1286
1286
headers = mimetools .Message (StringIO (
1287
1287
'Content-type: %s\n Content-length: %d\n Last-modified: %s\n ' %
1288
1288
(mtype or 'text/plain' , size , modified )))
1289
1289
if host :
1290
1290
host , port = splitport (host )
1291
1291
if not host or \
1292
1292
(not port and socket .gethostbyname (host ) in self .get_names ()):
1293
- return addinfourl (open (localfile , 'rb' ),
1294
- headers , 'file://' + host + file )
1293
+ if host :
1294
+ origurl = 'file://' + host + filename
1295
+ else :
1296
+ origurl = 'file://' + filename
1297
+ return addinfourl (open (localfile , 'rb' ), headers , origurl )
1295
1298
except OSError , msg :
1296
1299
# urllib2 users shouldn't expect OSErrors coming from urlopen()
1297
1300
raise URLError (msg )
You can’t perform that action at this time.
0 commit comments