'For keeping same behavior with v2 API, filter out microversions
HTTP header and microversions field in header \'Vary\'.'

def _filter_response_headers(self, response):

    if (wsgi.API_VERSION_REQUEST_HEADER in response.headers):
        del response.headers[wsgi.API_VERSION_REQUEST_HEADER]
    if (wsgi.LEGACY_API_VERSION_REQUEST_HEADER in response.headers):
        del response.headers[wsgi.LEGACY_API_VERSION_REQUEST_HEADER]
    if ('Vary' in response.headers):
        vary_headers = response.headers['Vary'].split(',')
        filtered_vary = []
        for vary in vary_headers:
            vary = vary.strip()
            if ((vary == wsgi.API_VERSION_REQUEST_HEADER) or (vary == wsgi.LEGACY_API_VERSION_REQUEST_HEADER)):
                continue
            filtered_vary.append(vary)
        if filtered_vary:
            response.headers['Vary'] = ','.join(filtered_vary)
        else:
            del response.headers['Vary']
    return response
