mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
Merged revisions 66634 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66634 | benjamin.peterson | 2008-09-26 21:49:54 -0500 (Fri, 26 Sep 2008) | 7 lines give ftplib a real test suite A asyncore based mock ftp server is used to test the protocol. This is all thanks to Giampaolo Rodola #3939 (Barry gave me permission to do this before final on IRC.) ........
This commit is contained in:
parent
f2e9368021
commit
be17a11721
2 changed files with 434 additions and 39 deletions
|
@ -71,6 +71,7 @@ all_errors = (Error, IOError, EOFError)
|
|||
|
||||
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
|
||||
CRLF = '\r\n'
|
||||
B_CRLF = b'\r\n'
|
||||
|
||||
# The class itself
|
||||
class FTP:
|
||||
|
@ -472,9 +473,9 @@ class FTP:
|
|||
while 1:
|
||||
buf = fp.readline()
|
||||
if not buf: break
|
||||
if buf[-2:] != CRLF:
|
||||
if buf[-1] in CRLF: buf = buf[:-1]
|
||||
buf = buf + CRLF
|
||||
if buf[-2:] != B_CRLF:
|
||||
if buf[-1] in B_CRLF: buf = buf[:-1]
|
||||
buf = buf + B_CRLF
|
||||
conn.sendall(buf)
|
||||
if callback: callback(buf)
|
||||
conn.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue