Use constants for HTTP headers (#10313)
* Use constants for HTTP headers * Fix ordering * Move 'no-cache' to platform
This commit is contained in:
1 parent
e64803e701
commit
de9d19d6f4
36 files changed
+408
-444
No files matched your search
@@ -4,19 +4,20 @@ Support for monitoring NZBGet NZB client.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.nzbget/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from aiohttp.hdrs import CONTENT_TYPE
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_NAME, CONF_PORT,
|
||||
CONF_SSL, CONTENT_TYPE_JSON, CONF_MONITORED_VARIABLES)
|
||||
CONF_SSL, CONF_HOST, CONF_NAME, CONF_PORT, CONF_PASSWORD, CONF_USERNAME,
|
||||
CONTENT_TYPE_JSON, CONF_MONITORED_VARIABLES)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -145,7 +146,7 @@ class NZBGetAPI(object):
|
||||
"""Initialize NZBGet API and set headers needed later."""
|
||||
self.api_url = api_url
|
||||
self.status = None
|
||||
self.headers = {'content-type': CONTENT_TYPE_JSON}
|
||||
self.headers = {CONTENT_TYPE: CONTENT_TYPE_JSON}
|
||||
|
||||
if username is not None and password is not None:
|
||||
self.auth = (username, password)
|
||||
@@ -155,7 +156,7 @@ class NZBGetAPI(object):
|
||||
|
||||
def post(self, method, params=None):
|
||||
"""Send a POST request and return the response as a dict."""
|
||||
payload = {"method": method}
|
||||
payload = {'method': method}
|
||||
|
||||
if params:
|
||||
payload['params'] = params
|
||||
|
||||
Reference in new issue
Block a user