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):
12761276 import email .utils
12771277 import mimetypes
12781278 host = req .get_host ()
1279- file = req .get_selector ()
1280- localfile = url2pathname (file )
1279+ filename = req .get_selector ()
1280+ localfile = url2pathname (filename )
12811281 try :
12821282 stats = os .stat (localfile )
12831283 size = stats .st_size
12841284 modified = email .utils .formatdate (stats .st_mtime , usegmt = True )
1285- mtype = mimetypes .guess_type (file )[0 ]
1285+ mtype = mimetypes .guess_type (filename )[0 ]
12861286 headers = mimetools .Message (StringIO (
12871287 'Content-type: %s\n Content-length: %d\n Last-modified: %s\n ' %
12881288 (mtype or 'text/plain' , size , modified )))
12891289 if host :
12901290 host , port = splitport (host )
12911291 if not host or \
12921292 (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 )
12951298 except OSError , msg :
12961299 # urllib2 users shouldn't expect OSErrors coming from urlopen()
12971300 raise URLError (msg )
You can’t perform that action at this time.
0 commit comments