def mangleResponse(self, response): ''' This method mangles the response. @param response: This is the response to mangle. @return: A mangled version of the response. ''' body = response.getBody() for regex, string in self._res_body_manglers: body = regex.sub(string, body) response.setBody(body) header_string = headersToString(response.getHeaders()) for regex, string in self._res_head_manglers: header_string = regex.sub(string, header_string) response.setHeaders(stringToHeaders(header_string)) if self._res_body_manglers and self._user_option_fix_content_len: response = self._fixContentLen(response) return response
def mangleRequest(self, request ): ''' This method mangles the request. @param request: This is the request to mangle. @return: A mangled version of the request. ''' data = request.getData() for regex, string in self._req_body_manglers: data = regex.sub( string, data ) header_string = headersToString( request.getHeaders() ) for regex, string in self._req_head_manglers: header_string = regex.sub( string, header_string ) header_dict = stringToHeaders( header_string ) request = createFuzzableRequestRaw( request.getMethod() , request.getURL(), data, header_dict ) return request