Skip to content

Commit

Permalink
feat: add host header
Browse files Browse the repository at this point in the history
  • Loading branch information
hartym committed Mar 18, 2024
1 parent 3c7faec commit 4e66779
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion harp_apps/proxy/controllers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import UTC, datetime
from functools import cached_property
from typing import Optional
from urllib.parse import urlencode, urljoin
from urllib.parse import urlencode, urljoin, urlparse

import httpx
from httpx import AsyncClient, codes
Expand Down Expand Up @@ -40,6 +40,8 @@ def __init__(self, url, *, http_client: AsyncClient, dispatcher=None, name=None)
self.name = name or self.name
self._dispatcher = dispatcher or self._dispatcher

self.parsed_url = urlparse(self.url)

async def adispatch(self, event_id, event=None):
"""
Shortcut method to dispatch an event using the controller's dispatcher, if there is one.
Expand Down Expand Up @@ -67,6 +69,7 @@ async def __call__(self, request: HttpRequest):
tags[k[7:]] = v
elif k not in ("host",):
headers.append((k, v))
headers.append(("host", self.parsed_url.netloc))

transaction = await self._create_transaction_from_request(request, tags=tags)
await request.join()
Expand Down

0 comments on commit 4e66779

Please sign in to comment.