Kaydet (Commit) 833a8d86 authored tarafından Guido van Rossum's avatar Guido van Rossum

SF patch #454553 by Walter Dörwald: add content-type to FTP URLs, like

for urllib.
üst 845fc48b
......@@ -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]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment