Commit c3bab08b authored by Amos Latteier's avatar Amos Latteier

Finished cookie support for FTP server. This allows you to use UserDB and...

Finished cookie support for FTP server. This allows you to use UserDB and etcUserDB cookie authentication with FTP.
parent 03087c40
...@@ -104,7 +104,12 @@ class FTPRequest(HTTPRequest): ...@@ -104,7 +104,12 @@ class FTPRequest(HTTPRequest):
stdin=StringIO() stdin=StringIO()
env=self._get_env(path, command, channel, stdin) env=self._get_env(path, command, channel, stdin)
HTTPRequest.__init__(self, stdin, env, response, clean=1) HTTPRequest.__init__(self, stdin, env, response, clean=1)
# support for cookies and cookie authentication
self.cookies=channel.cookies self.cookies=channel.cookies
if not self.cookies.has_key('__ac') and channel.userid != 'anonymous':
self.cookies['__ac']=encodestring('%s:%s' %
(channel.userid, channel.password))
for k,v in self.cookies.items(): for k,v in self.cookies.items():
if not self.other.has_key(k): if not self.other.has_key(k):
self.other[k]=v self.other[k]=v
......
...@@ -97,6 +97,18 @@ class FTPResponse(HTTPResponse): ...@@ -97,6 +97,18 @@ class FTPResponse(HTTPResponse):
Response to an FTP command Response to an FTP command
""" """
def setCookie(self, name, value, **kw):
self.cookies[name]=value
def appendCookie(self, name, value):
self.cookies[name]=self.cookies[name] + value
def expireCookie(self, name, **kw):
del self.cookies[name]
def _cookie_list(self):
return []
def _finish(self): def _finish(self):
self.stdout.finish(self) self.stdout.finish(self)
......
...@@ -104,7 +104,12 @@ class FTPRequest(HTTPRequest): ...@@ -104,7 +104,12 @@ class FTPRequest(HTTPRequest):
stdin=StringIO() stdin=StringIO()
env=self._get_env(path, command, channel, stdin) env=self._get_env(path, command, channel, stdin)
HTTPRequest.__init__(self, stdin, env, response, clean=1) HTTPRequest.__init__(self, stdin, env, response, clean=1)
# support for cookies and cookie authentication
self.cookies=channel.cookies self.cookies=channel.cookies
if not self.cookies.has_key('__ac') and channel.userid != 'anonymous':
self.cookies['__ac']=encodestring('%s:%s' %
(channel.userid, channel.password))
for k,v in self.cookies.items(): for k,v in self.cookies.items():
if not self.other.has_key(k): if not self.other.has_key(k):
self.other[k]=v self.other[k]=v
......
...@@ -97,6 +97,18 @@ class FTPResponse(HTTPResponse): ...@@ -97,6 +97,18 @@ class FTPResponse(HTTPResponse):
Response to an FTP command Response to an FTP command
""" """
def setCookie(self, name, value, **kw):
self.cookies[name]=value
def appendCookie(self, name, value):
self.cookies[name]=self.cookies[name] + value
def expireCookie(self, name, **kw):
del self.cookies[name]
def _cookie_list(self):
return []
def _finish(self): def _finish(self):
self.stdout.finish(self) self.stdout.finish(self)
......
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