toxuin / alarmserver

IP Camera Alarm Server to MQTT
MIT License
145 stars 34 forks source link

Dropped body part on Linux w/ Dahua #22

Open MiKoKappa opened 1 year ago

MiKoKappa commented 1 year ago

Hi! I have been testing alarm server with Dahua model ITC415-PW6M-IZ-C2, which has cgi-bin/snapManager.cgi API route for event management. On Windows 10, go version 1.19.2 everything works like a charm. On Linux Ubuntu Server, go version 1.19.3 the function part.Read from lib multipart reads out only about a half of data from response body. The other half of byte array is filled with zeros.

The issue only appears for bigger payloads (i.e. 3925 bytes, the n value from calling part.Read is only 1281).

Could you please give some advice how to address this issue? Thank you in advance.

MiKoKappa commented 1 year ago

Managed to get full request body by using io.ReadFull in function readEvents of server.go in dahua folder as so: _, err = io.ReadFull(part,body) instead of _, err = part.Read(body).