mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.11] gh-81403: Fix for CacheFTPHandler in urllib (GH-13951) (#103705)
* gh-81403: Fix for CacheFTPHandler in urllib (GH-13951)
bpo-37222: Fix for CacheFTPHandler in urllib
A call to FTP.ntransfercmd must be followed by FTP.voidresp to clear
the "end transfer" message. Without this, the client and server get
out of sync, which will result in an error if the FTP instance is
reused to open a second URL. This scenario occurs for even the most
basic usage of CacheFTPHandler.
Reverts the patch merged as a resolution to bpo-16270 and adds a test
case for the CacheFTPHandler in test_urllib2net.py.
(cherry picked from commit e38bebb9ee
)
Co-authored-by: Dan Hemberger <846186+hemberger@users.noreply.github.com>
Co-authored-by: Senthil Kumaran <senthil@python.org>
* Added NEWS entry.
---------
Co-authored-by: Dan Hemberger <846186+hemberger@users.noreply.github.com>
Co-authored-by: Senthil Kumaran <senthil@python.org>
This commit is contained in:
parent
a43dbe13e2
commit
6e25228b2e
3 changed files with 11 additions and 0 deletions
|
@ -2469,7 +2469,13 @@ class ftpwrapper:
|
|||
return (ftpobj, retrlen)
|
||||
|
||||
def endtransfer(self):
|
||||
if not self.busy:
|
||||
return
|
||||
self.busy = 0
|
||||
try:
|
||||
self.ftp.voidresp()
|
||||
except ftperrors():
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
self.keepalive = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue