1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 12:29:08 +00:00

Use custom user agent string for aiohttp (#3033)

This commit is contained in:
Joakim Sørensen
2021-07-28 14:46:37 +02:00
committed by GitHub
parent 419f603571
commit 9497f85db9
3 changed files with 23 additions and 1 deletions

View File

@@ -5,13 +5,14 @@ import asyncio
from datetime import datetime
import logging
import os
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional, TypeVar
import aiohttp
import sentry_sdk
from .config import CoreConfig
from .const import ENV_SUPERVISOR_DEV
from .const import ENV_SUPERVISOR_DEV, SERVER_SOFTWARE
from .docker import DockerAPI
from .utils.dt import UTC, get_time_zone
@@ -88,6 +89,11 @@ class CoreSys:
self._jobs: Optional[JobManager] = None
self._security: Optional[Security] = None
# Set default header for aiohttp
self._websession._default_headers = MappingProxyType(
{aiohttp.hdrs.USER_AGENT: SERVER_SOFTWARE}
)
@property
def dev(self) -> bool:
"""Return True if we run dev mode."""