diff options
Diffstat (limited to 'webmentions_ssg/tasks/discovery.py')
| -rw-r--r-- | webmentions_ssg/tasks/discovery.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/webmentions_ssg/tasks/discovery.py b/webmentions_ssg/tasks/discovery.py index 98f3fd5..ddf5817 100644 --- a/webmentions_ssg/tasks/discovery.py +++ b/webmentions_ssg/tasks/discovery.py @@ -30,8 +30,7 @@ class PermanentSenderError(SenderError): def resolve_endpoint(response: httpx.Response, href: str) -> str: - """ - Resolve and validate a discovered Webmention endpoint. + """Resolve and validate a discovered Webmention endpoint. :param response: Response from which the endpoint was discovered. :param href: Endpoint reference to resolve. @@ -51,8 +50,7 @@ def resolve_endpoint(response: httpx.Response, href: str) -> str: def parse_link_value(value: str) -> tuple[str, set[str]] | None: - """ - Parse a Link header value into its target and relations. + """Parse a Link header value into its target and relations. :param value: Link header value to parse. :return: Link target and relation names, or ``None`` if the value is invalid. @@ -81,8 +79,7 @@ def parse_link_value(value: str) -> tuple[str, set[str]] | None: def endpoint_from_headers(response: httpx.Response) -> str | None: - """ - Find a Webmention endpoint in the response Link headers. + """Find a Webmention endpoint in the response Link headers. :param response: HTTP response whose headers should be inspected. :return: First valid advertised Webmention endpoint, or ``None`` if none @@ -105,8 +102,7 @@ def endpoint_from_headers(response: httpx.Response) -> str | None: def endpoint_from_html(response: httpx.Response, body: bytes) -> str | None: - """ - Find a Webmention endpoint in an HTML document. + """Find a Webmention endpoint in an HTML document. ``link`` and ``a`` elements are inspected in document order. @@ -156,8 +152,7 @@ def read_target_body(response: httpx.Response) -> bytes: def discover_webmention_endpoint(client: httpx.Client, target: str) -> str | None: - """ - Discover the Webmention endpoint advertised by a target URL. + """Discover the Webmention endpoint advertised by a target URL. Endpoint discovery first checks the response to a HEAD request and then falls back to a GET request, inspecting both HTTP Link headers and supported HTML @@ -202,8 +197,7 @@ def discover_webmention_endpoint(client: httpx.Client, target: str) -> str | Non def post_webmention( client: httpx.Client, *, endpoint: str, source: str, target: str ) -> tuple[int, str | None]: - """ - Send a Webmention to a discovered endpoint. + """Send a Webmention to a discovered endpoint. :param client: HTTP client to use for the request. :param endpoint: Webmention endpoint URL. |
