def get_response(self, http_request, uri, response_headers): uri = URL(uri) try: callback = uri.get_querystring()['callback'][0] except KeyError: callback = 'default' body = '%s({})' % callback response_headers['Content-Type'] = 'application/javascript' return self.status, response_headers, body
def get_response(self, http_request, uri, response_headers): """ Overwrite the mock response with one simple objective: add a delay which depends on the length of the redos parameter. """ response_headers.update({'status': self.status}) response_headers.update(self.headers) uri = URL(uri) qs = uri.get_querystring() redos_param = qs.get('redos')[0] delay = len(redos_param) / 13.0 time.sleep(delay) return self.status, response_headers, self.body
def test_url_with_repeated_parameter_names(self): u = URL('http://w3af.com/?id=3&id=4') self.assertEqual(u.get_querystring(), QueryString([(u'id', [u'3', u'4'])]))