aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-07-19 09:22:33 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-07-19 09:23:11 -0400
commit45aaaf33f00e3d05456394775802d7551b20757c (patch)
treeec7d075dbf0c12ad42af52c0cdc248627ee803b1
parent54fef1025358a087012142580436b2a494ca8665 (diff)
downloadb4-45aaaf33f00e3d05456394775802d7551b20757c.tar.gz
submit: compress tracking data in the header
Reduce the size of the X-b4-tracking header by gzip-compressing the json output before base64-ing it. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/submit.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/b4/submit.py b/b4/submit.py
index 5622179..6acbf25 100644
--- a/b4/submit.py
+++ b/b4/submit.py
@@ -22,6 +22,7 @@ import email
import pathlib
import base64
import textwrap
+import gzip
# from nacl.signing import SigningKey
# from nacl.encoding import Base64Encoder
@@ -491,8 +492,9 @@ def send(cover_commit: str, cmdargs: argparse.Namespace) -> None:
cmsg.add_header('Subject', csubject)
# Store tracking info in the header in a safe format, which should allow us to
# fully restore our work from the already sent series.
- b64tracking = base64.b64encode(json.dumps(tracking).encode()).decode()
- cmsg.add_header('X-b4-tracking', ' '.join(textwrap.wrap(b64tracking, width=78)))
+ ztracking = gzip.compress(bytes(json.dumps(tracking), 'utf-8'))
+ b64tracking = base64.b64encode(ztracking)
+ cmsg.add_header('X-b4-tracking', ' '.join(textwrap.wrap(b64tracking.decode(), width=78)))
cmsg.set_payload(body, charset='utf-8')
if cmdargs.prefixes:
prefixes = list(cmdargs.prefixes)