Skip to content

Commit

Permalink
Support passthrough of AsyncHTTPTransport (vocodedev#603)
Browse files Browse the repository at this point in the history
Support passthrough of AsyncHTTPTransport object
  • Loading branch information
vocode-petern authored Jul 5, 2024
1 parent 918412c commit 41f38bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/streaming/action/test_external_actions_requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from typing import Any, Callable, Dict

import httpx
import pytest
from httpx import Request, Response
from pytest_httpx import HTTPXMock
Expand Down Expand Up @@ -65,6 +66,7 @@ async def test_send_request_responses(
JSON_SCHEMA,
base64.b64encode(os.urandom(32)).decode(),
additional_payload_values={"call_id": "call_id"},
transport=httpx.AsyncHTTPTransport(retries=3, verify=True),
)

assert response.success is expected_success
Expand Down
2 changes: 1 addition & 1 deletion vocode/streaming/action/external_actions_requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async def send_request(
payload: Dict[str, Any],
signature_secret: str,
additional_payload_values: Dict[str, Any] = {},
transport: httpx.AsyncHTTPTransport = httpx.AsyncHTTPTransport(retries=2),
) -> ExternalActionResponse:
encoded_payload = json.dumps({"payload": payload} | additional_payload_values).encode(
"utf-8"
Expand All @@ -63,7 +64,6 @@ async def send_request(
"x-vocode-signature": self._encode_payload(encoded_payload, signature_secret),
}

transport = httpx.AsyncHTTPTransport(retries=2)
async with httpx.AsyncClient(
headers=headers,
transport=transport,
Expand Down

0 comments on commit 41f38bc

Please sign in to comment.