@noita-ts/pollnet 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async.d.ts +1 -0
- package/dist/async.lua +4 -4
- package/package.json +1 -1
package/dist/async.d.ts
CHANGED
package/dist/async.lua
CHANGED
|
@@ -111,7 +111,7 @@ function HttpResponse.prototype.____constructor(self, status, headers, body)
|
|
|
111
111
|
self.headers = headers
|
|
112
112
|
self.body = body
|
|
113
113
|
end
|
|
114
|
-
function HttpResponse.read(
|
|
114
|
+
function HttpResponse.read(socket)
|
|
115
115
|
local msgs, ____error = socket:await_n(3)
|
|
116
116
|
if not msgs then
|
|
117
117
|
error(
|
|
@@ -120,7 +120,7 @@ function HttpResponse.read(self, socket)
|
|
|
120
120
|
)
|
|
121
121
|
end
|
|
122
122
|
local statusStr, headersStr, respBody = unpack(msgs, 1, 3)
|
|
123
|
-
local status = tonumber((string.match("^%d+"
|
|
123
|
+
local status = tonumber((string.match(statusStr, "^%d+"))) or 500
|
|
124
124
|
return __TS__New(____exports.HttpResponse, status, headersStr, respBody)
|
|
125
125
|
end
|
|
126
126
|
function HttpResponse.prototype.parseHeaders(self)
|
|
@@ -159,9 +159,9 @@ function HttpClient.prototype.____constructor(self, reactor)
|
|
|
159
159
|
self.reactor = reactor
|
|
160
160
|
end
|
|
161
161
|
function HttpClient.prototype.get(self, url, headers)
|
|
162
|
-
return self.reactor:spawn(function() return ____exports.HttpResponse
|
|
162
|
+
return self.reactor:spawn(function() return ____exports.HttpResponse.read(pollnet.http_get(url, headers, false)) end)
|
|
163
163
|
end
|
|
164
164
|
function HttpClient.prototype.post(self, url, headers, body)
|
|
165
|
-
return self.reactor:spawn(function() return ____exports.HttpResponse
|
|
165
|
+
return self.reactor:spawn(function() return ____exports.HttpResponse.read(pollnet.http_post(url, headers, body, false)) end)
|
|
166
166
|
end
|
|
167
167
|
return ____exports
|