Commit 442d1e96 authored by Amos Latteier's avatar Amos Latteier

Fixed upload response bug which caused problems when uploading multiple files...

Fixed upload response bug which caused problems when uploading multiple files with the mput command.
parent 057904e3
...@@ -25,6 +25,8 @@ ZServer Changes ...@@ -25,6 +25,8 @@ ZServer Changes
Using PCGI under IIS, now PATH_INFO begins with a / Using PCGI under IIS, now PATH_INFO begins with a /
Fixed FTP passive mode response message IP address. Fixed FTP passive mode response message IP address.
Fixed multiple file upload problem where response gets out of synch.
Known Bugs Known Bugs
...@@ -45,6 +47,8 @@ ZServer Changes ...@@ -45,6 +47,8 @@ ZServer Changes
remove cruft. remove cruft.
test with latest Zope from CVS. (done)
fix medusa select_trigger under win32. fix medusa select_trigger under win32.
re-write Zope installers to install a ZServer start script. re-write Zope installers to install a ZServer start script.
......
...@@ -137,7 +137,7 @@ FTP Authorization ...@@ -137,7 +137,7 @@ FTP Authorization
""" """
from PubCore import handle from PubCore import handle
from medusa.ftp_server import ftp_channel, ftp_server from medusa.ftp_server import ftp_channel, ftp_server, recv_channel
from medusa import asyncore, asynchat, filesys from medusa import asyncore, asynchat, filesys
from FTPResponse import make_response from FTPResponse import make_response
from FTPRequest import FTPRequest from FTPRequest import FTPRequest
...@@ -373,9 +373,9 @@ class zope_ftp_channel(ftp_channel): ...@@ -373,9 +373,9 @@ class zope_ftp_channel(ftp_channel):
self.respond ('553 restart on STOR not yet supported') self.respond ('553 restart on STOR not yet supported')
return return
# XXX Check for possible problems first? Like authorization... # XXX Check for possible problems first?
# But how? Once we agree to receive the file, can we still # Right now we are limited in the errors we can issue, since
# bail later? # we agree to accept the file before checking authorization
fd=ContentReceiver(self.stor_callback, line[1]) fd=ContentReceiver(self.stor_callback, line[1])
self.respond ( self.respond (
...@@ -384,8 +384,8 @@ class zope_ftp_channel(ftp_channel): ...@@ -384,8 +384,8 @@ class zope_ftp_channel(ftp_channel):
line[1] line[1]
) )
) )
self.make_recv_channel (fd) self.make_recv_channel(fd)
def stor_callback(self,path,data): def stor_callback(self,path,data):
'callback to do the STOR, after we have the input' 'callback to do the STOR, after we have the input'
response=make_response(self.stor_completion) response=make_response(self.stor_completion)
...@@ -393,13 +393,14 @@ class zope_ftp_channel(ftp_channel): ...@@ -393,13 +393,14 @@ class zope_ftp_channel(ftp_channel):
handle(self.module,request,response) handle(self.module,request,response)
def stor_completion(self,response): def stor_completion(self,response):
status=response.getStatus() status=response.getStatus()
if status in (200,201,204,302): if status in (200,201,204,302):
self.respond('257 STOR command successful.') self.client_dc.channel.respond('226 Transfer complete.')
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.client_dc.channel.respond('426 Unauthorized.')
else: else:
self.respond('550 Error creating file.') self.client_dc.channel.respond('426 Error creating file.')
self.client_dc.close()
def cmd_dele(self, line): def cmd_dele(self, line):
if len (line) != 2: if len (line) != 2:
...@@ -459,7 +460,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -459,7 +460,7 @@ class zope_ftp_channel(ftp_channel):
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.respond('530 Unauthorized.')
else: else:
repond('550 Error removing directory.') self.respond('550 Error removing directory.')
def cmd_user(self, line): def cmd_user(self, line):
'specify user name' 'specify user name'
...@@ -519,7 +520,21 @@ class zope_ftp_channel(ftp_channel): ...@@ -519,7 +520,21 @@ class zope_ftp_channel(ftp_channel):
def cmd_appe(self, line): def cmd_appe(self, line):
self.respond('502 Command not implemented.') self.respond('502 Command not implemented.')
# Override ftp server receive channel reponse mechanism
# XXX hack alert, this should probably be redone in a more OO way.
def handle_close (self):
"""response and closure of channel is delayed."""
s = self.channel.server
s.total_files_in.increment()
s.total_bytes_in.increment(self.bytes_in.as_long())
self.fd.close()
self.readable=lambda :0 # don't call close again
recv_channel.handle_close=handle_close
class ContentReceiver: class ContentReceiver:
"Write-only file object used to receive data from FTP" "Write-only file object used to receive data from FTP"
......
...@@ -25,6 +25,8 @@ ZServer Changes ...@@ -25,6 +25,8 @@ ZServer Changes
Using PCGI under IIS, now PATH_INFO begins with a / Using PCGI under IIS, now PATH_INFO begins with a /
Fixed FTP passive mode response message IP address. Fixed FTP passive mode response message IP address.
Fixed multiple file upload problem where response gets out of synch.
Known Bugs Known Bugs
...@@ -45,6 +47,8 @@ ZServer Changes ...@@ -45,6 +47,8 @@ ZServer Changes
remove cruft. remove cruft.
test with latest Zope from CVS. (done)
fix medusa select_trigger under win32. fix medusa select_trigger under win32.
re-write Zope installers to install a ZServer start script. re-write Zope installers to install a ZServer start script.
......
...@@ -137,7 +137,7 @@ FTP Authorization ...@@ -137,7 +137,7 @@ FTP Authorization
""" """
from PubCore import handle from PubCore import handle
from medusa.ftp_server import ftp_channel, ftp_server from medusa.ftp_server import ftp_channel, ftp_server, recv_channel
from medusa import asyncore, asynchat, filesys from medusa import asyncore, asynchat, filesys
from FTPResponse import make_response from FTPResponse import make_response
from FTPRequest import FTPRequest from FTPRequest import FTPRequest
...@@ -373,9 +373,9 @@ class zope_ftp_channel(ftp_channel): ...@@ -373,9 +373,9 @@ class zope_ftp_channel(ftp_channel):
self.respond ('553 restart on STOR not yet supported') self.respond ('553 restart on STOR not yet supported')
return return
# XXX Check for possible problems first? Like authorization... # XXX Check for possible problems first?
# But how? Once we agree to receive the file, can we still # Right now we are limited in the errors we can issue, since
# bail later? # we agree to accept the file before checking authorization
fd=ContentReceiver(self.stor_callback, line[1]) fd=ContentReceiver(self.stor_callback, line[1])
self.respond ( self.respond (
...@@ -384,8 +384,8 @@ class zope_ftp_channel(ftp_channel): ...@@ -384,8 +384,8 @@ class zope_ftp_channel(ftp_channel):
line[1] line[1]
) )
) )
self.make_recv_channel (fd) self.make_recv_channel(fd)
def stor_callback(self,path,data): def stor_callback(self,path,data):
'callback to do the STOR, after we have the input' 'callback to do the STOR, after we have the input'
response=make_response(self.stor_completion) response=make_response(self.stor_completion)
...@@ -393,13 +393,14 @@ class zope_ftp_channel(ftp_channel): ...@@ -393,13 +393,14 @@ class zope_ftp_channel(ftp_channel):
handle(self.module,request,response) handle(self.module,request,response)
def stor_completion(self,response): def stor_completion(self,response):
status=response.getStatus() status=response.getStatus()
if status in (200,201,204,302): if status in (200,201,204,302):
self.respond('257 STOR command successful.') self.client_dc.channel.respond('226 Transfer complete.')
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.client_dc.channel.respond('426 Unauthorized.')
else: else:
self.respond('550 Error creating file.') self.client_dc.channel.respond('426 Error creating file.')
self.client_dc.close()
def cmd_dele(self, line): def cmd_dele(self, line):
if len (line) != 2: if len (line) != 2:
...@@ -459,7 +460,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -459,7 +460,7 @@ class zope_ftp_channel(ftp_channel):
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.respond('530 Unauthorized.')
else: else:
repond('550 Error removing directory.') self.respond('550 Error removing directory.')
def cmd_user(self, line): def cmd_user(self, line):
'specify user name' 'specify user name'
...@@ -519,7 +520,21 @@ class zope_ftp_channel(ftp_channel): ...@@ -519,7 +520,21 @@ class zope_ftp_channel(ftp_channel):
def cmd_appe(self, line): def cmd_appe(self, line):
self.respond('502 Command not implemented.') self.respond('502 Command not implemented.')
# Override ftp server receive channel reponse mechanism
# XXX hack alert, this should probably be redone in a more OO way.
def handle_close (self):
"""response and closure of channel is delayed."""
s = self.channel.server
s.total_files_in.increment()
s.total_bytes_in.increment(self.bytes_in.as_long())
self.fd.close()
self.readable=lambda :0 # don't call close again
recv_channel.handle_close=handle_close
class ContentReceiver: class ContentReceiver:
"Write-only file object used to receive data from FTP" "Write-only file object used to receive data from FTP"
......
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