2828from Cryptodome .Protocol .KDF import PBKDF2
2929from Cryptodome .PublicKey import RSA
3030from Cryptodome .Signature import PKCS1_v1_5
31+ from requests .structures import CaseInsensitiveDict
3132
3233from librespot import util
3334from librespot import Version
@@ -80,7 +81,7 @@ def build_request(
8081 self ,
8182 method : str ,
8283 suffix : str ,
83- headers : typing .Union [None , typing . Dict [str , str ]],
84+ headers : typing .Union [None , CaseInsensitiveDict [str , str ]],
8485 body : typing .Union [None , bytes ],
8586 url : typing .Union [None , str ],
8687 ) -> requests .PreparedRequest :
@@ -89,7 +90,7 @@ def build_request(
8990 :param method: str:
9091 :param suffix: str:
9192 :param headers: typing.Union[None:
92- :param typing.Dict [str:
93+ :param CaseInsensitiveDict [str:
9394 :param str]]:
9495 :param body: typing.Union[None:
9596 :param bytes]:
@@ -106,7 +107,7 @@ def build_request(
106107 request = requests .PreparedRequest ()
107108 request .method = method
108109 request .data = body
109- request .headers = {}
110+ request .headers = CaseInsensitiveDict ()
110111 if headers is not None :
111112 request .headers = headers
112113 request .headers ["Authorization" ] = "Bearer {}" .format (
@@ -122,15 +123,15 @@ def send(
122123 self ,
123124 method : str ,
124125 suffix : str ,
125- headers : typing .Union [None , typing . Dict [str , str ]],
126+ headers : typing .Union [None , CaseInsensitiveDict [str , str ]],
126127 body : typing .Union [None , bytes ],
127128 ) -> requests .Response :
128129 """
129130
130131 :param method: str:
131132 :param suffix: str:
132133 :param headers: typing.Union[None:
133- :param typing.Dict [str:
134+ :param CaseInsensitiveDict [str:
134135 :param str]]:
135136 :param body: typing.Union[None:
136137 :param bytes]:
@@ -145,7 +146,7 @@ def sendToUrl(
145146 method : str ,
146147 url : str ,
147148 suffix : str ,
148- headers : typing .Union [None , typing . Dict [str , str ]],
149+ headers : typing .Union [None , CaseInsensitiveDict [str , str ]],
149150 body : typing .Union [None , bytes ],
150151 ) -> requests .Response :
151152 """
@@ -154,7 +155,7 @@ def sendToUrl(
154155 :param url: str:
155156 :param suffix: str:
156157 :param headers: typing.Union[None:
157- :param typing.Dict [str:
158+ :param CaseInsensitiveDict [str:
158159 :param str]]:
159160 :param body: typing.Union[None:
160161 :param bytes]:
@@ -327,10 +328,10 @@ def __client_token(self):
327328 resp = requests .post (
328329 "https://clienttoken.spotify.com/v1/clienttoken" ,
329330 proto_req .SerializeToString (),
330- headers = {
331+ headers = CaseInsensitiveDict ( {
331332 "Accept" : "application/x-protobuf" ,
332333 "Content-Encoding" : "" ,
333- },
334+ }) ,
334335 )
335336
336337 ApiClient .StatusCodeException .check_status (resp )
@@ -604,10 +605,10 @@ def wait_for_listener(self) -> None:
604605 return
605606 self .__message_listeners_lock .wait ()
606607
607- def __get_headers (self , obj : typing .Any ) -> dict [str , str ]:
608+ def __get_headers (self , obj : typing .Any ) -> CaseInsensitiveDict [str , str ]:
608609 headers = obj .get ("headers" )
609610 if headers is None :
610- return {}
611+ return CaseInsensitiveDict ()
611612 return headers
612613
613614 class ConnectionHolder (Closeable ):
@@ -1212,12 +1213,12 @@ def mercury(self) -> MercuryClient:
12121213 raise RuntimeError ("Session isn't authenticated!" )
12131214 return self .__mercury_client
12141215
1215- def on_message (self , uri : str , headers : typing . Dict [str , str ],
1216+ def on_message (self , uri : str , headers : CaseInsensitiveDict [str , str ],
12161217 payload : bytes ):
12171218 """
12181219
12191220 :param uri: str:
1220- :param headers: typing.Dict [str:
1221+ :param headers: CaseInsensitiveDict [str:
12211222 :param str]:
12221223 :param payload: bytes:
12231224
@@ -2331,10 +2332,10 @@ def login5(self, scopes: typing.List[str]) -> typing.Union[StoredToken, None]:
23312332 response = requests .post (
23322333 "https://login5.spotify.com/v3/login" ,
23332334 data = login5_request .SerializeToString (),
2334- headers = {
2335+ headers = CaseInsensitiveDict ( {
23352336 "Content-Type" : "application/x-protobuf" ,
23362337 "Accept" : "application/x-protobuf"
2337- })
2338+ }))
23382339
23392340 if response .status_code == 200 :
23402341 login5_response = Login5 .LoginResponse ()
0 commit comments