Rename. `httppost` function to `form`
parent
9d36abc5d6
commit
430ebb927e
|
@ -23,7 +23,7 @@ curl:easy()
|
||||||
curl:easy()
|
curl:easy()
|
||||||
:setopt_url('http://posttestserver.com/post.php')
|
:setopt_url('http://posttestserver.com/post.php')
|
||||||
:setopt_writefunction(io.write)
|
:setopt_writefunction(io.write)
|
||||||
:setopt_httppost(curl.httppost()
|
:setopt_httppost(curl.form()
|
||||||
:add_content("test_content", "some data", {
|
:add_content("test_content", "some data", {
|
||||||
"MyHeader: SomeValue"
|
"MyHeader: SomeValue"
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
-- @module lcurl
|
-- @module lcurl
|
||||||
|
do
|
||||||
|
|
||||||
--- Create HTTP multipart object.
|
--- Create HTTP multipart object.
|
||||||
--
|
--
|
||||||
-- @treturn[1] httppost new curl HTTP Post object context
|
-- @treturn[1] httpform new curl HTTP Post object context
|
||||||
function httppost() end
|
function form() end
|
||||||
|
|
||||||
--- Create Easy object
|
--- Create Easy object
|
||||||
--
|
--
|
||||||
|
@ -27,8 +27,10 @@ function version() end
|
||||||
-- if proto.HTTP then ... -- libcurl support http protocol
|
-- if proto.HTTP then ... -- libcurl support http protocol
|
||||||
function version_info() end
|
function version_info() end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- HTTP multipart/formdata object
|
--- HTTP multipart/formdata object
|
||||||
-- @type httppost
|
-- @type httpform
|
||||||
--
|
--
|
||||||
do
|
do
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ do
|
||||||
-- @tparam[opt] string type provides the content-type for this part
|
-- @tparam[opt] string type provides the content-type for this part
|
||||||
-- @tparam[opt] table headers specifies extra headers for the form POST section
|
-- @tparam[opt] table headers specifies extra headers for the form POST section
|
||||||
-- @return[1] self
|
-- @return[1] self
|
||||||
function httppost:add_content() end
|
function httpform:add_content() end
|
||||||
|
|
||||||
--- Add new part to form.
|
--- Add new part to form.
|
||||||
--
|
--
|
||||||
|
@ -49,7 +51,7 @@ function httppost:add_content() end
|
||||||
-- @tparam[opt] string type provides the content-type for this part
|
-- @tparam[opt] string type provides the content-type for this part
|
||||||
-- @tparam[opt] table headers specifies extra headers for the form POST section
|
-- @tparam[opt] table headers specifies extra headers for the form POST section
|
||||||
-- @return[1] self
|
-- @return[1] self
|
||||||
function httppost:add_buffer() end
|
function httpform:add_buffer() end
|
||||||
|
|
||||||
--- Add new part to form.
|
--- Add new part to form.
|
||||||
--
|
--
|
||||||
|
@ -60,7 +62,7 @@ function httppost:add_buffer() end
|
||||||
-- By default it is basename of path.
|
-- By default it is basename of path.
|
||||||
-- @tparam[opt] table headers specifies extra headers for the form POST section
|
-- @tparam[opt] table headers specifies extra headers for the form POST section
|
||||||
-- @return[1] self
|
-- @return[1] self
|
||||||
function httppost:add_file() end
|
function httpform:add_file() end
|
||||||
|
|
||||||
--- Serialize multipart/formdata HTTP POST chain.
|
--- Serialize multipart/formdata HTTP POST chain.
|
||||||
--
|
--
|
||||||
|
@ -68,7 +70,7 @@ function httppost:add_file() end
|
||||||
--
|
--
|
||||||
-- @usage print(post:get())
|
-- @usage print(post:get())
|
||||||
--
|
--
|
||||||
function httppost:get() end
|
function httpform:get() end
|
||||||
|
|
||||||
--- Serialize multipart/formdata HTTP POST chain.
|
--- Serialize multipart/formdata HTTP POST chain.
|
||||||
--
|
--
|
||||||
|
@ -84,11 +86,11 @@ function httppost:get() end
|
||||||
-- post:get(table.insert, t)
|
-- post:get(table.insert, t)
|
||||||
-- print(table.concat(t))
|
-- print(table.concat(t))
|
||||||
--
|
--
|
||||||
function httppost:get() end
|
function httpform:get() end
|
||||||
|
|
||||||
--- Serialize multipart/formdata HTTP POST chain.
|
--- Serialize multipart/formdata HTTP POST chain.
|
||||||
--
|
--
|
||||||
-- This call same as httppost:get(writer.write, writer)
|
-- This call same as httpform:get(writer.write, writer)
|
||||||
--
|
--
|
||||||
-- @tparam object writer
|
-- @tparam object writer
|
||||||
-- @return[1] self
|
-- @return[1] self
|
||||||
|
@ -97,11 +99,11 @@ function httppost:get() end
|
||||||
-- f = io.open(...)
|
-- f = io.open(...)
|
||||||
-- post:get(f)
|
-- post:get(f)
|
||||||
--
|
--
|
||||||
function httppost:get() end
|
function httpform:get() end
|
||||||
|
|
||||||
--- Free multipart/formdata.
|
--- Free multipart/formdata.
|
||||||
--
|
--
|
||||||
function httppost:free() end
|
function httpform:free() end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -251,9 +253,9 @@ function easy:setopt_readfunction() end
|
||||||
|
|
||||||
--- Set HTTP multipart/formdata
|
--- Set HTTP multipart/formdata
|
||||||
--
|
--
|
||||||
-- @tparam httppost data
|
-- @tparam httpform data
|
||||||
-- @return[1] self
|
-- @return[1] self
|
||||||
function easy:setopt_httppost() end
|
function easy:setopt_httpform() end
|
||||||
|
|
||||||
--- Set HTTP multipart/formdata
|
--- Set HTTP multipart/formdata
|
||||||
--
|
--
|
||||||
|
|
|
@ -121,7 +121,7 @@ function easy:perform(opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function easy:post(data)
|
function easy:post(data)
|
||||||
local post = curl.httppost()
|
local post = curl.form()
|
||||||
local ok, err
|
local ok, err
|
||||||
for k, v in data do
|
for k, v in data do
|
||||||
if type(v) == "string" then
|
if type(v) == "string" then
|
||||||
|
|
|
@ -74,7 +74,7 @@ static int lcurl_version_info(lua_State *L){
|
||||||
|
|
||||||
static const struct luaL_Reg lcurl_functions[] = {
|
static const struct luaL_Reg lcurl_functions[] = {
|
||||||
{"error", lcurl_error_new },
|
{"error", lcurl_error_new },
|
||||||
{"httppost", lcurl_hpost_new },
|
{"form", lcurl_hpost_new },
|
||||||
{"easy", lcurl_easy_new },
|
{"easy", lcurl_easy_new },
|
||||||
{"version", lcurl_version },
|
{"version", lcurl_version },
|
||||||
{"version_info", lcurl_version_info },
|
{"version_info", lcurl_version_info },
|
||||||
|
|
Loading…
Reference in New Issue