Changeset ce85a5f in mod_gnutls


Ignore:
Timestamp:
Dec 4, 2019, 9:36:10 AM (10 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
2e736df
Parents:
851173b
git-author:
Fiona Klute <fiona.klute@…> (12/04/19 09:19:25)
git-committer:
Fiona Klute <fiona.klute@…> (12/04/19 09:36:10)
Message:

Move code to run a TestRequest? into the class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/https-test-client.py

    r851173b rce85a5f  
    112112                f'method={self.method!r}, headers={self.headers!r}, '
    113113                f'expect={self.expect!r})')
     114
     115    def run(self, conn):
     116        try:
     117            conn.request(self.method, self.path, headers=self.headers)
     118            resp = conn.getresponse()
     119        except ConnectionResetError as err:
     120            if self.expects_conn_reset():
     121                print('connection reset as expected.')
     122                return
     123            else:
     124                raise err
     125        body = resp.read().decode()
     126        print(format_response(resp, body))
     127        self.check_response(resp, body)
    114128
    115129    def _check_body(self, body):
     
    376390        for act in test_actions:
    377391            if type(act) is TestRequest:
    378                 try:
    379                     conn.request(act.method, act.path, headers=act.headers)
    380                     resp = conn.getresponse()
    381                 except ConnectionResetError as err:
    382                     if act.expects_conn_reset():
    383                         print('connection reset as expected.')
    384                         break
    385                     else:
    386                         raise err
    387                 body = resp.read().decode()
    388                 print(format_response(resp, body))
    389                 act.check_response(resp, body)
     392                act.run(conn)
    390393            elif type(act) is TestRaw10:
    391394                act.run(command, conn.timeout)
Note: See TracChangeset for help on using the changeset viewer.