From 8edc5c72a76ac227cac97bb39a15b194f618cc1c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 7 Apr 2020 15:08:54 -0700 Subject: Add user agent header to que client --- Run/Que/client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Run/Que/client.py b/Run/Que/client.py index 8d90e7a..6a91d0c 100755 --- a/Run/Que/client.py +++ b/Run/Que/client.py @@ -55,19 +55,25 @@ def main(argv=None): # loop until ^C while not time.sleep(1): with request.urlopen( - f"{args.host}/{args.target}", data=data, timeout=MAX_TIMEOUT + f"{args.host}/{args.target}", + data=data, + timeout=MAX_TIMEOUT, + headers={"User-Agent": "Que/Client"}, ) as req: pass else: with request.urlopen( - f"{args.host}/{args.target}", data=data, timeout=MAX_TIMEOUT + f"{args.host}/{args.target}", + data=data, + timeout=MAX_TIMEOUT, + headers={"User-Agent": "Que/Client"}, ) as req: pass else: # no input data, do a read instead params = urllib.parse.urlencode({"poll": args.poll}) url = f"{args.host}/{args.target}?{params}" - with request.urlopen(url) as req: + with request.urlopen(url, headers={"User-Agent": "Que/Client"}) as req: if args.poll: while not time.sleep(1): msg = req.readline().decode("utf-8").strip() -- cgit v1.2.3