示例#1
0
 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
示例#2
0
 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
示例#3
0
 def no_action():
     return MessageUpdate()
示例#4
0
 def proxy_action(action):
     update = MessageUpdate()
     # i.e. MessageUpdate.ACTION_FOLLOW_RULES
     update.action = action
     return update
示例#5
0
 def get_body(data, encoding='utf-8'):
     update = MessageUpdate()
     update.action = MessageUpdate.GET_BODY
     update.body = base64.b64encode(data).decode(encoding)
     return update
示例#6
0
 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
示例#7
0
 def update_request_headers(headers):
     update = MessageUpdate()
     update.action = MessageUpdate.UPDATE_REQUEST_HEADERS
     update.headers = headers
     return update
示例#8
0
 def update_parameter(param_name, param_value):
     update = MessageUpdate()
     update.action = MessageUpdate.UPDATE_PARAMETER
     update.paramName = param_name
     update.paramValue = param_value
     return update
示例#9
0
 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
示例#10
0
 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
示例#11
0
 def del_parameter(param_name):
     update = MessageUpdate()
     update.action = MessageUpdate.DEL_PARAMETER
     update.paramName = param_name
     return update