Hi, I made this post yesterday:
It addressed the problem that I was getting a request closed when using GET http socket from Awair Local API. However, after digging around on a packet level, I realized that the socket.http sent request lines and headers on separate commands and it seemed the Awair did not like that at all, so what was done was basically combining metat.__index:sendrequestline(method, uri) function and metat.__index:sendheaders(tosend) to one function:
function metat.__index:sendrequestlineX(method, uri, tosend)
local reqline = string.format(“%s %s HTTP/1.1\r\n”, method or “GET”, uri)
local canonic = headers.canonic
local h = “\r\n”
for f, v in base.pairs(tosend) do
h = (canonic[f] or f) … ": " … v … “\r\n” … h
return self.try(self.c:send(reqline .. h))
And it works, I can now get the data from my Awair Local API. However, here comes another problem.
I needed to modify the “socket.http” in order to achieve this. I tried referencing it as a local module folder instead of calling from the SmartThings library, and of course it didn’t work as I was missing many dependencies such as mime.lua and .core files. I wonder if there is any way for me to access the SmartThings libraries and modify the socket module. Any suggested workaround will also be welcome and greatly appreciated. Thank you very much in advance.