mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-07 02:43:02 +03:00
scripts/test-sender: Support --gzip=bad
This commit is contained in:
parent
7537a300c0
commit
ad8fc57df3
@ -27,10 +27,15 @@ send_message:
|
|||||||
s = requests.Session()
|
s = requests.Session()
|
||||||
|
|
||||||
if args.gzip:
|
if args.gzip:
|
||||||
if args.gzip == 'good':
|
# We assume that the argparse setup is enforcing the value being
|
||||||
|
# valid, i.e. `'good'` if it's not `'bad'`.
|
||||||
msg = zlib.compress(msg.encode('utf-8'))
|
msg = zlib.compress(msg.encode('utf-8'))
|
||||||
s.headers['Content-Encoding'] = 'gzip'
|
s.headers['Content-Encoding'] = 'gzip'
|
||||||
|
|
||||||
|
if args.gzip == 'bad':
|
||||||
|
# Prepend a character so it's not a valid gzip header
|
||||||
|
msg = b'w' + msg
|
||||||
|
|
||||||
r = s.post(upload_url, data=msg)
|
r = s.post(upload_url, data=msg)
|
||||||
|
|
||||||
print(f'Response: {r!r}')
|
print(f'Response: {r!r}')
|
||||||
@ -55,7 +60,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
__parser.add_argument(
|
__parser.add_argument(
|
||||||
'--gzip',
|
'--gzip',
|
||||||
choices=('good'),
|
choices=('good', 'bad'),
|
||||||
help='Specify to gzip-compress the request body',
|
help='Specify to gzip-compress the request body',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user