ReMe/reme/components/outbound_proxy/fixed_http.py
jinliyl 54fa3381d7
Some checks failed
CI and Release / Docker / Build and test / amd64 (push) Has been cancelled
CI and Release / Docker / Build and test / arm64 (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.14 (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / GitHub Actions (push) Has been cancelled
CI / Python tests / Hermes embedded - ubuntu-latest (push) Has been cancelled
CI / Python tests / Hermes embedded - windows-latest (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI and Release / Docker / Publish multi-platform tags (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
refactor(core): reorganize the ReMe runtime and shared helpers (#769)
* refactor(core): reorganize the ReMe runtime and shared helpers

* test(status): import the base component from its canonical module

* test: remove redundant unit checks

* refactor(core): use canonical runtime imports and shared CLI discovery

Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service.

* fix(cli): honor caller config when service replay is incomplete

Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.
2026-11-20 22:06:46 +08:00

40 lines
1.6 KiB
Python

"""Outbound proxy backend wrapping an existing HTTP proxy."""
from urllib.parse import urlsplit
from .base import BaseOutboundProxy, OutboundProxyEndpoint
from ...core.registry import R
@R.register("fixed_http")
class FixedHttpOutboundProxy(BaseOutboundProxy):
"""Publish an externally managed HTTP proxy without owning its lifecycle."""
def __init__(self, url: str = "", **kwargs) -> None:
super().__init__(**kwargs)
self.url = url
async def _start(self) -> None:
self._endpoint = OutboundProxyEndpoint(http_url=self._validate_url())
async def _close(self) -> None:
self._endpoint = None
def _validate_url(self) -> str:
try:
parsed = urlsplit(self.url)
port = parsed.port
except ValueError as exc:
raise ValueError("Outbound proxy configuration invalid: malformed fixed HTTP proxy URL.") from exc
if parsed.scheme != "http":
raise ValueError("Outbound proxy configuration invalid: fixed proxy URL must use http://.")
if not parsed.hostname or port is None:
raise ValueError("Outbound proxy configuration invalid: fixed proxy URL must include host and port.")
if parsed.username is not None or parsed.password is not None:
raise ValueError("Outbound proxy configuration invalid: fixed proxy URL must not contain userinfo.")
if parsed.query or parsed.fragment:
raise ValueError(
"Outbound proxy configuration invalid: fixed proxy URL must not contain query or fragment.",
)
return self.url