'Removes any headers from the WSGI environment as per the
middleware configuration for incoming requests.
:param env: The WSGI environment for the request.'

def _clean_incoming_headers(self, env):

    for h in env.keys():
        if (h in self.incoming_allow_headers):
            continue
        for p in self.incoming_allow_headers_startswith:
            if h.startswith(p):
                break
        else:
            if (h in self.incoming_remove_headers):
                del env[h]
                continue
            for p in self.incoming_remove_headers_startswith:
                if h.startswith(p):
                    del env[h]
                    break
