Changeset 407ca6e in mod_gnutls


Ignore:
Timestamp:
Jan 14, 2020, 4:25:48 PM (11 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, master, proxy-ticket
Children:
346c03b
Parents:
b22def6
git-author:
Fiona Klute <fiona.klute@…> (01/14/20 06:49:21)
git-committer:
Fiona Klute <fiona.klute@…> (01/14/20 16:25:48)
Message:

TestRequest? and TestReq10: Support request body

This will allow testing e.g. POST requests.

Also remove the redundant repr(self) method in TestReq10, the
inherited method works just fine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/tests.py

    rb22def6 r407ca6e  
    209209    """
    210210    yaml_tag = '!request'
    211     def __init__(self, path, method='GET', headers=dict(),
     211    def __init__(self, path, method='GET', body=None, headers=dict(),
    212212                 expect=dict(status=200)):
    213213        self.method = method
    214214        self.path = path
     215        self.body = body
    215216        self.headers = headers
    216217        self.expect = expect
     
    218219    def __repr__(self):
    219220        return (f'{self.__class__.__name__!s}(path={self.path!r}, '
    220                 f'method={self.method!r}, headers={self.headers!r}, '
    221                 f'expect={self.expect!r})')
     221                f'method={self.method!r}, body={self.body!r}, '
     222                f'headers={self.headers!r}, expect={self.expect!r})')
    222223
    223224    def run(self, conn, response_log=None):
    224225        try:
    225             conn.request(self.method, self.path, headers=self.headers)
     226            conn.request(self.method, self.path, body=self.body,
     227                         headers=self.headers)
    226228            resp = conn.getresponse()
    227229            if self.expects_conn_reset():
     
    351353        super().__init__(**kwargs)
    352354
    353     def __repr__(self):
    354         return (f'{self.__class__.__name__!s}'
    355                 f'(method={self.method!r}, path={self.path!r}, '
    356                 f'headers={self.headers!r}, expect={self.expect!r})')
    357 
    358355    def run(self, command, timeout=None, conn_log=None, response_log=None):
    359356        req = f'{self.method} {self.path} HTTP/1.0\r\n'
     
    361358            req = req + f'{name}: {value}\r\n'
    362359        req = req + f'\r\n'
     360        if self.body:
     361            req = req + self.body
    363362        proc = subprocess.Popen(command,
    364363                                stdout=subprocess.PIPE,
Note: See TracChangeset for help on using the changeset viewer.