'Removes any headers as per the middleware configuration for
outgoing responses.
:param headers: A WSGI start_response style list of headers,
[(\'header1\', \'value), (\'header2\', \'value),
:returns: The same headers list, but with some headers
removed as per the middlware configuration for
outgoing responses.'

def _clean_outgoing_headers(self, headers):

    headers = HeaderKeyDict(headers)
    for h in headers.keys():
        if (h in self.outgoing_allow_headers):
            continue
        for p in self.outgoing_allow_headers_startswith:
            if h.startswith(p):
                break
        else:
            if (h in self.outgoing_remove_headers):
                del headers[h]
                continue
            for p in self.outgoing_remove_headers_startswith:
                if h.startswith(p):
                    del headers[h]
                    break
    return headers.items()
