This change is bought on by the realisation that the addition of HTTP support to the plugin framework was done in an unsustainable and non-pythonic way. The addition of specific HTTP parameters to several functions means that the addition of any other protocols will require constant updates to the API which will be unsustainable, particularly once the plugin framework makes it into the stable release code base where plugin authors have every right to expect API stability.
Plugins that have not been updated will throw this error on startup:
Code: Select all
'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''.
This means:
Code: Select all
def onMessage(self, Connection, Data, Status, Extra):
Code: Select all
def onMessage(self, Connection, Data):
For HTTP connections the Data parameters is now a dictionary so this code:
Code: Select all
def onMessage(self, Connection, Data):
DumpHTTPResponseToLog(Data)
def DumpHTTPResponseToLog(httpDict):
if isinstance(httpDict, dict):
Domoticz.Log("HTTP Details ("+str(len(httpDict))+"):")
for x in httpDict:
if isinstance(httpDict[x], dict):
Domoticz.Log("--->'"+x+" ("+str(len(httpDict[x]))+"):")
for y in httpDict[x]:
Domoticz.Log("------->'" + y + "':'" + str(httpDict[x][y]) + "'")
else:
Domoticz.Log("--->'" + x + "':'" + str(httpDict[x]) + "'")
Code: Select all
HTTP Details (3):
--->'Status':'302'
--->'Data':'b'\n\n302 Moved\nThe document has moved\nhere.\r\n\r\n''
--->'Headers (6):
------->'Cache-Control':'private'
------->'Content-Length':'262'
------->'Date':'Sat, 29 Jul 2017 01:45:56 GMT'
------->'Referrer-Policy':'no-referrer'
------->'Location':'http://www.google.com.au/?gfe_rd=cr&ei=1Oh7WfiqJIfp8weC2YPQAQ'
------->'Content-Type':'text/html; charset=UTF-8'
Code: Select all
httpClientConn.Send({"Verb":"GET", "URL":"/page.html", "Headers": {"Connection": "keep-alive", "Accept": "Content-Type: text/html; charset=UTF-8"}})
- Initial built in support for UDP/IP. The Kodi example shows working Python for this
- The HTTP protocol understands HHTP responses which means plugins can act as simple web servers. There is a new example called HTTP Listener which shows this
- For HTTP a 'Content-length' header is inserted automatically if there is data but the header was not supplied in messages
- Added option to logger to show thread ids (-logthreadids) to help troubleshooting, off by default