aboutsummaryrefslogtreecommitdiff
path: root/src/http.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.lua')
-rw-r--r--src/http.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/http.lua b/src/http.lua
index d6bcc91..f2fff01 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -346,11 +346,13 @@ end
346 return 1, code, headers, status 346 return 1, code, headers, status
347end 347end
348 348
349local function srequest(u, b) 349-- turns an url and a body into a generic request
350local function genericform(u, b)
350 local t = {} 351 local t = {}
351 local reqt = { 352 local reqt = {
352 url = u, 353 url = u,
353 sink = ltn12.sink.table(t) 354 sink = ltn12.sink.table(t),
355 target = t
354 } 356 }
355 if b then 357 if b then
356 reqt.source = ltn12.source.string(b) 358 reqt.source = ltn12.source.string(b)
@@ -360,8 +362,15 @@ local function srequest(u, b)
360 } 362 }
361 reqt.method = "POST" 363 reqt.method = "POST"
362 end 364 end
363 local code, headers, status = socket.skip(1, trequest(reqt)) 365 return reqt
364 return table.concat(t), code, headers, status 366end
367
368_M.genericform = genericform
369
370local function srequest(u, b)
371 local reqt = genericform(u, b)
372 local _, code, headers, status = trequest(reqt)
373 return table.concat(reqt.target), code, headers, status
365end 374end
366 375
367_M.request = socket.protect(function(reqt, body) 376_M.request = socket.protect(function(reqt, body)