tchellomello / python-amcrest

A Python 2.7/3.x module for Amcrest and Dahua Cameras using the SDK HTTP API.
GNU General Public License v2.0
216 stars 76 forks source link

Improve event data handling #212

Closed flacjacket closed 2 years ago

flacjacket commented 2 years ago

It looks like the first two characters after the ContentLength is specified are a carriage return. This has thrown off the json string parsing leading to hand rolling regex which fails in odd ways (see #204). Now, pull out a couple extra characters to get past this leading carriage return. If the leading characters are not there, we should have a trailing \r\n\r\n which is safe to add, and will just be stripped out. With this change in place, we are able to use json parsing on data, with a fallback to sending the data string.