Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/pingintel_api/api_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import os
import pathlib
from typing import IO, Collection, overload

import gzip
import json
import click
import requests
import requests
Expand Down Expand Up @@ -110,7 +111,17 @@ def post(self, url, **kwargs):
self.logger.debug(f"POST {url}")
if "data" in kwargs:
self.logger.debug(f"POST data: {kwargs['data']}")
# breakpoint()

if (
"headers" in kwargs
and "content-encoding" in kwargs["headers"]
and kwargs["headers"]["content-encoding"] == "gzip"
):
self.logger.debug(f"Converting raw POST json to gzip data")
request_body = gzip.compress(json.dumps(kwargs["json"]).encode("utf-8"))
kwargs["data"] = request_body
del kwargs["json"]

return self.session.post(url, **kwargs)

def _create_session(self):
Expand Down