Arduino esp8266 REST server

simple test.py:

import urllib3

http = urllib3.PoolManager()

r = http.request('GET', '192.168.1.146')

print ("status:", r.status)
print ("data:", r.data)

With the result:

status: 200
data: b'on\n\n'

When I try to integrate with a REST sensor in HA I get a lot of timeout errors and buffer TypeError: getresponse() got an unexpected keyword argument ‘buffering’

I’m trying to send:

---------------------------------------------------------------
HTTP/1.1 200 OK
Connection: close
Content-Type: application/json
on
---------------------------------------------------------------

maybe I shouldnt be using REST?

I ended up using a Command Line Sensor with CURL.