diff --git a/drivers/SmartThings/philips-hue/src/lunchbox/rest.lua b/drivers/SmartThings/philips-hue/src/lunchbox/rest.lua index 7e0817524c..c3752647ee 100644 --- a/drivers/SmartThings/philips-hue/src/lunchbox/rest.lua +++ b/drivers/SmartThings/philips-hue/src/lunchbox/rest.lua @@ -5,6 +5,8 @@ local lb_utils = require "lunchbox.util" local Request = require "luncheon.request" local Response = require "luncheon.response" +local api_version = require("version").api + local RestCallStates = { SEND = "Send", RECEIVE = "Receive", @@ -129,6 +131,11 @@ local function parse_chunked_response(original_response, sock) end local function handle_response(sock) + if api_version >= 9 then + local response, err = Response.tcp_source(sock) + if err or (not response) then return response, (err or "unknown error") end + return response, response:fill_body() + end -- called select right before passing in so we receive immediately local initial_recv, initial_err, partial = Response.source(function() return sock:receive('*l') end) diff --git a/drivers/SmartThings/sonos/src/lunchbox/rest.lua b/drivers/SmartThings/sonos/src/lunchbox/rest.lua index d0c4d413c4..4977aaf2f2 100644 --- a/drivers/SmartThings/sonos/src/lunchbox/rest.lua +++ b/drivers/SmartThings/sonos/src/lunchbox/rest.lua @@ -6,6 +6,8 @@ local utils = require "utils" local Request = require "luncheon.request" local Response = require "luncheon.response" +local api_version = require("version").api + local RestCallStates = { SEND = "Send", RECEIVE = "Receive", @@ -132,6 +134,11 @@ local function parse_chunked_response(original_response, sock) end local function handle_response(sock) + if api_version >= 9 then + local response, err = Response.tcp_source(sock) + if err or (not response) then return response, (err or "unknown error") end + return response, response:fill_body() + end -- called select right before passing in so we receive immediately local initial_recv, initial_err, partial = Response.source(function() return sock:receive('*l') end)