41
41
def valid_search_headers (headers : CaseInsensitiveDict ) -> bool :
42
42
"""Validate if this search is usable."""
43
43
# pylint: disable=invalid-name
44
- udn = headers .get ("_udn" ) # type: Optional[str]
45
- st = headers .get ("st" ) # type: Optional[str]
46
- location = headers .get ("location" , "" ) # type: str
44
+ udn = headers .get_lower ("_udn" ) # type: Optional[str]
45
+ st = headers .get_lower ("st" ) # type: Optional[str]
46
+ location = headers .get_lower ("location" , "" ) # type: str
47
47
return bool (
48
48
udn
49
49
and st
@@ -60,10 +60,10 @@ def valid_search_headers(headers: CaseInsensitiveDict) -> bool:
60
60
def valid_advertisement_headers (headers : CaseInsensitiveDict ) -> bool :
61
61
"""Validate if this advertisement is usable for connecting to a device."""
62
62
# pylint: disable=invalid-name
63
- udn = headers .get ("_udn" ) # type: Optional[str]
64
- nt = headers .get ("nt" ) # type: Optional[str]
65
- nts = headers .get ("nts" ) # type: Optional[str]
66
- location = headers .get ("location" , "" ) # type: str
63
+ udn = headers .get_lower ("_udn" ) # type: Optional[str]
64
+ nt = headers .get_lower ("nt" ) # type: Optional[str]
65
+ nts = headers .get_lower ("nts" ) # type: Optional[str]
66
+ location = headers .get_lower ("location" , "" ) # type: str
67
67
return bool (
68
68
udn
69
69
and nt
@@ -81,15 +81,15 @@ def valid_advertisement_headers(headers: CaseInsensitiveDict) -> bool:
81
81
def valid_byebye_headers (headers : CaseInsensitiveDict ) -> bool :
82
82
"""Validate if this advertisement has required headers for byebye."""
83
83
# pylint: disable=invalid-name
84
- udn = headers .get ("_udn" ) # type: Optional[str]
85
- nt = headers .get ("nt" ) # type: Optional[str]
86
- nts = headers .get ("nts" ) # type: Optional[str]
84
+ udn = headers .get_lower ("_udn" ) # type: Optional[str]
85
+ nt = headers .get_lower ("nt" ) # type: Optional[str]
86
+ nts = headers .get_lower ("nts" ) # type: Optional[str]
87
87
return bool (udn and nt and nts )
88
88
89
89
90
90
def extract_valid_to (headers : CaseInsensitiveDict ) -> datetime :
91
91
"""Extract/create valid to."""
92
- cache_control = headers .get ("cache-control" , "" )
92
+ cache_control = headers .get_lower ("cache-control" , "" )
93
93
match = CACHE_CONTROL_RE .search (cache_control )
94
94
if match :
95
95
max_age = int (match [1 ])
@@ -247,7 +247,7 @@ def ip_version_from_location(location: str) -> Optional[int]:
247
247
248
248
def location_changed (ssdp_device : SsdpDevice , headers : CaseInsensitiveDict ) -> bool :
249
249
"""Test if location changed for device."""
250
- new_location = headers .get ("location" , "" )
250
+ new_location = headers .get_lower ("location" , "" )
251
251
if not new_location :
252
252
return False
253
253
0 commit comments