Changeset 1c76ea7 in mod_gnutls


Ignore:
Timestamp:
Jan 21, 2020, 2:21:16 PM (3 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master
Children:
4a22ee6
Parents:
6fa6095
Message:

mgstest.tests: Encode request body as utf-8

HTTPConnection.request() defaults to latin-1 for texts, which leads to
trouble if someone writes odd characters into a test definition. ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/tests.py

    r6fa6095 r1c76ea7  
    213213        self.method = method
    214214        self.path = path
    215         self.body = body
     215        self.body = body.encode('utf-8') if body else None
    216216        self.headers = headers
    217217        self.expect = expect
     
    357357        for name, value in self.headers.items():
    358358            req = req + f'{name}: {value}\r\n'
    359         req = req + f'\r\n'
     359        req = req.encode('utf-8') + b'\r\n'
    360360        if self.body:
    361361            req = req + self.body
     
    367367                                bufsize=0)
    368368        try:
    369             outs, errs = proc.communicate(input=req.encode(),
    370                                           timeout=timeout)
     369            outs, errs = proc.communicate(input=req, timeout=timeout)
    371370        except TimeoutExpired:
    372371            proc.kill()
Note: See TracChangeset for help on using the changeset viewer.