Changed handlers (both mod_python and WSGI) to support setting multiple cookies per request

git-svn-id: http://code.djangoproject.com/svn/django/trunk@511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-08-15 22:47:41 +00:00
parent c727729183
commit d22e88898f
2 changed files with 6 additions and 6 deletions

View File

@ -164,11 +164,11 @@ class ModPythonHandler(BaseHandler):
def populate_apache_request(http_response, mod_python_req): def populate_apache_request(http_response, mod_python_req):
"Populates the mod_python request object with an HttpResponse" "Populates the mod_python request object with an HttpResponse"
mod_python_req.content_type = http_response['Content-Type'] or httpwrappers.DEFAULT_MIME_TYPE mod_python_req.content_type = http_response['Content-Type'] or httpwrappers.DEFAULT_MIME_TYPE
if http_response.cookies:
mod_python_req.headers_out['Set-Cookie'] = http_response.cookies.output(header='')
for key, value in http_response.headers.items(): for key, value in http_response.headers.items():
if key != 'Content-Type': if key != 'Content-Type':
mod_python_req.headers_out[key] = value mod_python_req.headers_out[key] = value
for c in http_response.cookies.values():
mod_python_req.headers_out.add('Set-Cookie', c.output(header=''))
mod_python_req.status = http_response.status_code mod_python_req.status = http_response.status_code
mod_python_req.write(http_response.get_content_as_string('utf-8')) mod_python_req.write(http_response.get_content_as_string('utf-8'))

View File

@ -138,9 +138,9 @@ class WSGIHandler(BaseHandler):
except KeyError: except KeyError:
status_text = 'UNKNOWN STATUS CODE' status_text = 'UNKNOWN STATUS CODE'
status = '%s %s' % (response.status_code, status_text) status = '%s %s' % (response.status_code, status_text)
response_headers = response.headers response_headers = response.headers.items()
if response.cookies: for c in response.cookies.values():
response_headers['Set-Cookie'] = response.cookies.output(header='') response_headers.append(('Set-Cookie', c.output(header='')))
output = [response.get_content_as_string('utf-8')] output = [response.get_content_as_string('utf-8')]
start_response(status, response_headers.items()) start_response(status, response_headers)
return output return output