maximvelichko / pyvera

A python library to control devices via the Vera hub
GNU General Public License v2.0
26 stars 30 forks source link

Manually specify response encoding #138

Closed vangorra closed 3 years ago

vangorra commented 3 years ago

Manually specify response encoding to avoid slowness caused by the chardet library when requests try to detect the encoding.

Documented here: https://github.com/home-assistant/core/issues/32876

Basically, the vera device does not include a character encoding when responding to calls. When requests sees no character encoding, requests uses the chardet to detect the character encoding based on the raw bytes returned. As documented in the home assistant issue, this is an intensive process. To avoid this issue, we are manually setting the encoding to utf-8. This will prevent requests from using chardet.