6 .add_custom_headers(self.header_list, self.header_dict)
7 .add_body_content(self.body_content)
10 local threadCode = 'local
command, channel = ...\n'
11 ..'local handle = io and io.popen and io.popen(
command)\n'
13 ..' local
stdout = handle:read(\'*a\')\n'
14 ..' local
ok, stderr = handle:close()\n'
15 ..' love.thread.getChannel(channel..\'
ok\'):push(
ok)\n'
16 ..' love.thread.getChannel(channel..\'
stdout\'):push(
stdout)\n'
17 ..' love.thread.getChannel(channel..\'stderr\'):push(stderr)\n'
19 ..' love.thread.getChannel(channel..\'
ok\'):push(false)\n'
20 ..' love.thread.getChannel(channel..\'stderr\'):push(\'
command failed\')\n'
24 self.
application.internal.
http.queue[
#self.application.internal.http.queue + 1] = self
25 thread = love.thread.newThread(threadCode)
26 thread:start(
command, tostring(self))
32 local channel = tostring(self)
33 local
ok = love.thread.getChannel(channel..
'ok'):pop()
35 local
stdout = love.thread.getChannel(channel..
'stdout'):pop() or
''
36 local stderr = love.thread.getChannel(channel..
'stderr'):pop() or
''
37 local index =
stdout:find(
"[^\n]*$") or 1
38 local status = tonumber(
stdout:sub(index))
40 self.std.http.ok =
false
41 self.std.http.error = stderr or
stdout or
'unknown error!'
43 self.std.http.ok =
http_util.is_ok(status)
44 self.std.http.body =
stdout:sub(1, index - 2)
45 self.std.http.status = status
58 while index <=
#application.internal.http.queue do
60 table.remove(
application.internal.http.queue, index)
local function stdout(self, format)
local function require(std, game, application)
local function install(std, game, application)
local function http_callback(self)
local function http_handler(self)
local function event_loop(std, game, application, evt)
resolve request
local function failed(self, handler_func)
local function http(std, game)
local function loop(std, game, application, dt)