def build_new_http_message(headers, body, encoding='utf-8'): update = MessageUpdate() # WARNING: this will overwrite the whole message, previous changes will be ignored! update.action = MessageUpdate.BUILD_HTTP_MESSAGE update.headers = headers update.body = base64.b64encode(body).decode(encoding) return update
def add_parameter(param_name, param_value, param_type): update = MessageUpdate() update.action = MessageUpdate.ADD_PARAMETER update.paramName = param_name update.paramValue = param_value update.paramType = param_type return update
def no_action(): return MessageUpdate()
def proxy_action(action): update = MessageUpdate() # i.e. MessageUpdate.ACTION_FOLLOW_RULES update.action = action return update
def get_body(data, encoding='utf-8'): update = MessageUpdate() update.action = MessageUpdate.GET_BODY update.body = base64.b64encode(data).decode(encoding) return update
def base64_decode_body(data, encoding='utf-8'): update = MessageUpdate() update.action = MessageUpdate.BASE64_DECODE_BODY update.body = base64.b64encode(data).decode(encoding) return update
def update_request_headers(headers): update = MessageUpdate() update.action = MessageUpdate.UPDATE_REQUEST_HEADERS update.headers = headers return update
def update_parameter(param_name, param_value): update = MessageUpdate() update.action = MessageUpdate.UPDATE_PARAMETER update.paramName = param_name update.paramValue = param_value return update
def replace_response_body(body, encoding='utf-8'): update = MessageUpdate() update.action = MessageUpdate.REPLACE_RESPONSE_BODY update.body = base64.b64encode(body).decode(encoding) return update
def replace_request_body(body, encoding='utf-8'): update = MessageUpdate() update.action = MessageUpdate.REPLACE_REQUEST_BODY update.body = base64.b64encode(body).decode(encoding) return update
def del_parameter(param_name): update = MessageUpdate() update.action = MessageUpdate.DEL_PARAMETER update.paramName = param_name return update