44"""
55import asyncio
66from http import HTTPStatus
7- import json
87import logging
98from urllib .parse import parse_qs , urlparse
109import uuid
2524from pyhap .util import long_to_bytes
2625
2726from .hap_crypto import hap_hkdf , pad_tls_nonce
28- from .util import to_hap_json
27+ from .util import to_hap_json , from_hap_json
2928
3029# iOS will terminate the connection if it does not respond within
3130# 10 seconds, so we only allow 9 seconds to avoid this.
@@ -614,7 +613,7 @@ def handle_set_characteristics(self):
614613 self .send_response (HTTPStatus .UNAUTHORIZED )
615614 return
616615
617- requested_chars = json . loads (self .request_body .decode ("utf-8" ))
616+ requested_chars = from_hap_json (self .request_body .decode ("utf-8" ))
618617 logger .debug (
619618 "%s: Set characteristics content: %s" , self .client_address , requested_chars
620619 )
@@ -639,7 +638,7 @@ def handle_prepare(self):
639638 self .send_response (HTTPStatus .UNAUTHORIZED )
640639 return
641640
642- request = json . loads (self .request_body .decode ("utf-8" ))
641+ request = from_hap_json (self .request_body .decode ("utf-8" ))
643642 logger .debug ("%s: prepare content: %s" , self .client_address , request )
644643
645644 response = self .accessory_handler .prepare (request , self .client_address )
@@ -744,7 +743,7 @@ def _send_tlv_pairing_response(self, data):
744743
745744 def handle_resource (self ):
746745 """Get a snapshot from the camera."""
747- data = json . loads (self .request_body .decode ("utf-8" ))
746+ data = from_hap_json (self .request_body .decode ("utf-8" ))
748747
749748 if self .accessory_handler .accessory .category == CATEGORY_BRIDGE :
750749 accessory = self .accessory_handler .accessory .accessories .get (data ["aid" ])
0 commit comments