Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect twirp url #82

Merged
merged 2 commits into from
Oct 31, 2023
Merged
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
11 changes: 7 additions & 4 deletions livekit-api/livekit/api/_twirp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

import aiohttp
from google.protobuf.message import Message
from urllib.parse import urlparse

DEFAULT_PREFIX = "/twirp"
DEFAULT_PREFIX = "twirp"


class TwirpError(Exception):
Expand Down Expand Up @@ -52,7 +53,9 @@ class TwirpErrorCode:

class TwirpClient:
def __init__(self, host: str, pkg: str, prefix: str = DEFAULT_PREFIX) -> None:
self.host = host
parse_res = urlparse(host)
host = f"http://{parse_res.netloc}/{parse_res.path}"
self.host = host.rstrip("/")
self.pkg = pkg
self.prefix = prefix
self.session = aiohttp.ClientSession()
Expand All @@ -69,8 +72,8 @@ async def request(
headers["Content-Type"] = "application/protobuf"

serialized_data = data.SerializeToString()
async with self.session.post(
url, headers=headers, data=serialized_data
async with self.session.request(
"post", url, headers=headers, data=serialized_data
) as resp:
if resp.status == 200:
return response_class.FromString(await resp.read())
Expand Down
Loading