Closed ignacio closed 11 years ago
Reading data in chunk from the request yields the wrong data:
local mock = require "wsapi.mock" local ws_request = require "wsapi.request" local test_app = function(wsapi_env) return 200, {}, coroutine.wrap(function() coroutine.yield(wsapi_env.input:read(2048)) coroutine.yield(wsapi_env.input:read(2048)) end) end local app = mock.make_handler(test_app) local data = ("AB"):rep(1024) .. ("CD"):rep(1024) local response, request = app:post("test", data, { ["Content-Length"] = #data, ["Content-Type"] = "text/plain" }) assert(response.body == data)
The problem is here: https://github.com/keplerproject/wsapi/blob/master/src/wsapi/mock.lua#L74
It should be:
local s = self.buffer:sub(self.bytes_read + 1, self.bytes_read + len)
Reading data in chunk from the request yields the wrong data:
The problem is here: https://github.com/keplerproject/wsapi/blob/master/src/wsapi/mock.lua#L74
It should be: