source: main/waeup.sirp/branches/multimechanize/trunk/examples/test_scripts/example_httplib.py @ 7546

Last change on this file since 7546 was 7541, checked in by uli, 13 years ago

Add sources copied from current multi-mechanize GIT repos.

File size: 786 bytes
Line 
1#
2#  Copyright (c) 2010 Corey Goldberg (corey@goldb.org)
3#  License: GNU LGPLv3
4#
5#  This file is part of Multi-Mechanize
6#
7
8
9import httplib
10import time
11
12
13
14class Transaction(object):
15    def __init__(self):
16        self.custom_timers = {}
17
18    def run(self):
19        start_timer = time.time()
20        conn = httplib.HTTPConnection('www.example.com')
21        conn.request('GET', '/')
22        resp = conn.getresponse()
23        content = resp.read()
24        latency = time.time() - start_timer
25
26        self.custom_timers['Example_Homepage'] = latency
27
28        assert (resp.status == 200), 'Bad HTTP Response'
29        assert ('Example Web Page' in content), 'Failed Content Verification'
30
31
32if __name__ == '__main__':
33    trans = Transaction()
34    trans.run()
35    print trans.custom_timers
Note: See TracBrowser for help on using the repository browser.