serkri / SmartEVSE-3

Smart Electric Vehicle Charging Station (EVSE)
MIT License
75 stars 26 forks source link

check post vars too on post requests #229

Open dbursem opened 11 months ago

dbursem commented 11 months ago

fixes https://github.com/serkri/SmartEVSE-3/issues/220

e.g.:

➜  SmartEVSE-3 git:(check-post-vars-on-api-calls-2) curl -v -d 'L1=11' -d 'L2=12' -d 'L3=13' -d 'battery_current=5' http://192.168.1.225/currents
*   Trying 192.168.1.225:80...
* Connected to 192.168.1.225 (192.168.1.225) port 80 (#0)
> POST /currents HTTP/1.1
> Host: 192.168.1.225
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 35
> Content-Type: application/x-www-form-urlencoded
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Length: 93
< Content-Type: application/json
< Connection: close
< Accept-Ranges: none
< 
* Closing connection 0
{"battery_current":5,"original":{"L":11,"":12,"SMART":13},"L":11,"":12,"SMART":13,"TOTAL":36}

old behaviour also still works:

➜  SmartEVSE-3 git:(check-post-vars-on-api-calls-2) curl -v -X POST http://192.168.1.225/currents\?L1\=21\&L2\=22\&L3\=23                                
*   Trying 192.168.1.225:80...
* Connected to 192.168.1.225 (192.168.1.225) port 80 (#0)
> POST /currents?L1=21&L2=22&L3=23 HTTP/1.1
> Host: 192.168.1.225
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Length: 73
< Content-Type: application/json
< Connection: close
< Accept-Ranges: none
< 
* Closing connection 0
{"original":{"L":21,"":22,"SMART":23},"L":21,"":22,"SMART":23,"TOTAL":66}%                                                                                                          ➜  SmartEVSE-3 git:(check-post-vars-on-api-calls-2)