'Merge the cookies that were set on this response with the
given `resp` object (which can be any WSGI application).
If the `resp` is a :class:`webob.Response` object, then the
other object will be modified in-place.'

def merge_cookies(self, resp):

    if (not self.headers.get('Set-Cookie')):
        return resp
    if isinstance(resp, Response):
        for header in self.headers.getall('Set-Cookie'):
            resp.headers.add('Set-Cookie', header)
        return resp
    else:
        c_headers = [h for h in self.headerlist if (h[0].lower() == 'set-cookie')]
        def repl_app(environ, start_response):
            def repl_start_response(status, headers, exc_info=None):
                return start_response(status, (headers + c_headers), exc_info=exc_info)
            return resp(environ, repl_start_response)
        return repl_app
