@nayelyz I patched this issue with the following change to http.lua. I donât view this as a permanent fix as this receive call should not be returning the extra HTTP/
prior to the 200. For the platform team, please let them know this behavior is specific to using asyncify
and is present in at least firmware v42. I donât have v43 yet to check there. Given the change in behavior by doing things like adding logging, this looks very much like a timing issue introduced by using asyncify
. Thanks.
function metat.__index:receivestatusline()
local status,ec = self.try(self.c:receive(5))
-- identify HTTP/0.9 responses, which do not contain a status line
-- this is just a heuristic, but is what the RFC recommends
if status ~= "HTTP/" then
if ec == "timeout" then
return 408
end
return nil, status
end
-- otherwise proceed reading a status line
status = self.try(self.c:receive("*l", status))
local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)"))
-- START PATCH TO GRAB CODE (Look for extra HTTP/ prior to the code)
if code == nil then
code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* HTTP/(%d%d%d)"))
end
-- END PATCH TO GRAB CODE
return self.try(base.tonumber(code), status)
end
Edit:
As I run this code, I am also seeing lines like this that have even more spurious HTTP/
's in the status
self.c:receive("*l", status) = HTTP/1.1 HTTP/200 OKHTTP/
self.c:receive("*l", status) = HTTP/1.1 HTTP/200HTTP/ OK
The patch is still working given that the regex fits, but the status is corrupted. I updated the patched section to this since the HTTP moves around
status = self.try(self.c:receive("*l", status))
-- START PATCH
local scrubbed, count = status:gsub('HTTP/','')
if count > 1 then
log.warn(string.format('self.c:receive("*l", status) = %s', status))
log.warn(string.format('scrubbed = %s', scrubbed))
end
local code = socket.skip(2, string.find(scrubbed, "%d*%.%d* (%d%d%d)"))
status = string.format('HTTP/%s', scrubbed)
-- END PATCH
return self.try(base.tonumber(code), status)