Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pubnub/request_handlers/async_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async def async_request(self, options_func, cancellation_event):
else:
data = "N/A"

logger.debug("[%s %s] %s" % (options.operation_type, response_info.http_version, data))
logger.debug(data)

if response.status not in (200, 307, 204):

Expand Down
2 changes: 1 addition & 1 deletion pubnub/request_handlers/async_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ async def async_request(self, options_func, cancellation_event):
else:
data = "N/A"

logger.debug("[%s %s] %s" % (options.operation_type, response_info.http_version, data))
logger.debug(data)

if response.status_code not in (200, 307, 204):

Expand Down
12 changes: 6 additions & 6 deletions pubnub/request_handlers/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,15 @@ def _invoke_request(self, p_options, e_options, base_origin):

try:
res = session.request(**args)

# Safely access response text - read content first for streaming responses
try:
logger.debug("[%s %s] %s" % (e_options.operation_type, res.http_version, res.text))
logger.debug("GOT %s" % res.text)
except httpx.ResponseNotRead:
content = res.content.decode('utf-8', errors='ignore')
logger.debug("[%s %s] %s" % (e_options.operation_type, res.http_version, content))
# For streaming responses, we need to read first
logger.debug("GOT %s" % res.content.decode('utf-8', errors='ignore'))
except Exception as e:
msg = "(content access failed: %s)" % str(e)
logger.debug("[%s %s] %s" % (e_options.operation_type, res.http_version, msg))
# Fallback logging in case of any response reading issues
logger.debug("GOT response (content access failed: %s)" % str(e))

except httpx.ConnectError as e:
if use_watchdog and self._watchdog.triggered:
Expand Down
7 changes: 1 addition & 6 deletions pubnub/request_handlers/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,7 @@ def _invoke_request(self, p_options, e_options, base_origin):

try:
res = self.session.request(**args)
http_ver = (
f"HTTP/{res.raw.version // 10}.{res.raw.version % 10}"
if res.raw and res.raw.version else "unknown"
)
logger.debug("[%s %s] %s" % (e_options.operation_type, http_ver, res.text))

logger.debug("GOT %s" % res.text)
except requests.exceptions.ConnectionError as e:
raise PubNubException(
pn_error=PNERR_CONNECTION_ERROR,
Expand Down
Loading