mirror of
https://github.com/python/cpython.git
synced 2024-11-25 10:54:51 +08:00
SF patch #454553 by Walter Dörwald: add content-type to FTP URLs, like
for urllib.
This commit is contained in:
parent
845fc48bf7
commit
833a8d8641
@ -956,11 +956,14 @@ class FTPHandler(BaseHandler):
|
||||
value in ('a', 'A', 'i', 'I', 'd', 'D'):
|
||||
type = value.upper()
|
||||
fp, retrlen = fw.retrfile(file, type)
|
||||
headers = ""
|
||||
mtype = mimetypes.guess_type(req.get_full_url())[0]
|
||||
if mtype:
|
||||
headers += "Content-Type: %s\n" % mtype
|
||||
if retrlen is not None and retrlen >= 0:
|
||||
sf = StringIO('Content-Length: %d\n' % retrlen)
|
||||
headers = mimetools.Message(sf)
|
||||
else:
|
||||
headers = noheaders()
|
||||
headers += "Content-Length: %d\n" % retrlen
|
||||
sf = StringIO(headers)
|
||||
headers = mimetools.Message(sf)
|
||||
return addinfourl(fp, headers, req.get_full_url())
|
||||
except ftplib.all_errors, msg:
|
||||
raise IOError, ('ftp error', msg), sys.exc_info()[2]
|
||||
|
Loading…
Reference in New Issue
Block a user