def handle_done(request, response): print('Headers:', response.headers) print('Code:', response.code) print('Version:', response.version) print('Reason:', response.reason) print('Data:', response.content()) die('Request done.')
def on_done(con, response): print('Headers:', response.headers) print('Code:', response.code) print('Version:', response.version) print('Reason:', response.reason) print('Data:', response.fd.read()) die()
def on_response(request, response): print('Headers:', response.headers) print('Code:', response.code) print('Version:', response.version) print('Reason:', response.reason) print('Data:', response.fd.read()) die('Request done.')
def handle_done(self, request, response): response_data = json.loads(response.content()) self.assertTrue(response_data['form'], self.data) self.assertTrue(response_data['args'], self.args) url = '%s?%s' % (self.url, urlencode(self.args)) self.assertTrue(response_data['url'], url) die()
def handle_empty(pool): print('All requests done!') die('Stopping...')
def handle_done(self, request, response): response_data = json.loads(response.content()) self.assertTrue(response_data['form'], self.data) die()
def handle_done(self, request, response): response_data = response.content() response_data = json.loads(response_data) self.assertEqual(self.url, response_data['url']) die()
def handle_done(self, request, response): response_data = response.content() response_data = json.loads(response_data) authorization = response_data['headers']['Authorization'] self.assertEqual(authorization, request.headers['authorization']) die()
from websnake import Get, BasicAuth, ResponseHandle, core, die def handle_response(request, response): print('Headers:', response.headers) print('Code:', response.code) print('Version:', response.version) print('Reason:', response.reason) if __name__ == '__main__': request = Get('http://httpbin.org/get', auth=BasicAuth('foo', 'bar')) request.add_map(ResponseHandle.RESPONSE, handle_response) request.add_map(ResponseHandle.DONE, lambda req, resp: die('Bye!')) core.gear.mainloop()