Commit 0ea180a2 authored by Jim Fulton's avatar Jim Fulton

Added support for retrying requests.

parent 95f9afd9
......@@ -99,11 +99,13 @@ import string
class FTPRequest(HTTPRequest):
def __init__(self, path, command, channel, response, stdin=None):
if stdin is None:
stdin=StringIO()
env=self._get_env(path, command, channel, stdin)
HTTPRequest.__init__(self, stdin, env, response, clean=1)
def __init__(self, path, command, channel, response, stdin=None,
environ=None):
if stdin is None: stdin=StringIO()
if environ is None:
environ=self._get_env(path, command, channel, stdin)
self._orig_env=environ
HTTPRequest.__init__(self, stdin, environ, response, clean=1)
# support for cookies and cookie authentication
self.cookies=channel.cookies
......@@ -114,6 +116,15 @@ class FTPRequest(HTTPRequest):
if not self.other.has_key(k):
self.other[k]=v
def retry(self):
r=self.__class__(stdin=self.stdin,
environ=self._orig_env,
response=self.response.retry(),
channel=self, # For my cookies
)
r._held=self._held
return r
def _get_env(self, path, command, channel, stdin):
"Returns a CGI style environment"
env={}
......
......@@ -264,6 +264,21 @@ class ChannelPipe:
self._close=1
self._request.reply_code=response.status
def retry(self):
"""Return a request object to be used in a retry attempt
"""
# This implementation is a bit lame, because it assumes that
# only stdout stderr were passed to the constructor. OTOH, I
# think that that's all that is ever passed.
r=self.__class__(stdout=self.stdout, stderr=self.stderr)
response._http_version=self._http_version
response._http_connection=self._http_connection
response._server_version=self._server_version
return r
def make_response(request, headers):
"Simple http response factory"
......@@ -276,3 +291,4 @@ def make_response(request, headers):
response._server_version=request.channel.server.SERVER_IDENT
return response
......@@ -99,11 +99,13 @@ import string
class FTPRequest(HTTPRequest):
def __init__(self, path, command, channel, response, stdin=None):
if stdin is None:
stdin=StringIO()
env=self._get_env(path, command, channel, stdin)
HTTPRequest.__init__(self, stdin, env, response, clean=1)
def __init__(self, path, command, channel, response, stdin=None,
environ=None):
if stdin is None: stdin=StringIO()
if environ is None:
environ=self._get_env(path, command, channel, stdin)
self._orig_env=environ
HTTPRequest.__init__(self, stdin, environ, response, clean=1)
# support for cookies and cookie authentication
self.cookies=channel.cookies
......@@ -114,6 +116,15 @@ class FTPRequest(HTTPRequest):
if not self.other.has_key(k):
self.other[k]=v
def retry(self):
r=self.__class__(stdin=self.stdin,
environ=self._orig_env,
response=self.response.retry(),
channel=self, # For my cookies
)
r._held=self._held
return r
def _get_env(self, path, command, channel, stdin):
"Returns a CGI style environment"
env={}
......
......@@ -264,6 +264,21 @@ class ChannelPipe:
self._close=1
self._request.reply_code=response.status
def retry(self):
"""Return a request object to be used in a retry attempt
"""
# This implementation is a bit lame, because it assumes that
# only stdout stderr were passed to the constructor. OTOH, I
# think that that's all that is ever passed.
r=self.__class__(stdout=self.stdout, stderr=self.stderr)
response._http_version=self._http_version
response._http_connection=self._http_connection
response._server_version=self._server_version
return r
def make_response(request, headers):
"Simple http response factory"
......@@ -276,3 +291,4 @@ def make_response(request, headers):
response._server_version=request.channel.server.SERVER_IDENT
return response
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