def scrub_response(response): if not SHOULD_SCRUB: return response response = response.copy() response = scrub_response_headers(response) body = response['body']['string'] try: body = zlib.decompress(response['body']['string'], WBITS).decode('utf8') except: should_recompress = False else: should_recompress = True body = replace_json_fields(body) body = util.replace_all_case_insensitive(body, settings.USERNAME, TESTING_USERNAME) if should_recompress: body = gzip_string(body) response['body']['string'] = body return response
def scrub_uri(uri): replaced = util.replace_all_case_insensitive(uri, settings.USERNAME, TESTING_USERNAME) return util.replace_all_case_insensitive(replaced, settings.PASSWORD, TESTING_PASSWORD)