From 4510730e374017768b3dd65abc4d0af2cc3554bc Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 28 Aug 2014 15:59:18 +0500 Subject: [PATCH] Fix. Wrong set headers on form:add_file() method. Add. SSL_XXX options. --- README.md | 12 ++++++------ src/lchttppost.c | 2 +- src/lcopteasy.h | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bc3bf16..aed64dd 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ luarocks install lcurl --server=https://rocks.moonscript.org/dev ```Lua -- HTTP Get -curl:easy() +curl.easy() :setopt_url('http://httpbin.org/get') :setopt_httpheader{ "X-Test-Header1: Header-Data1", @@ -43,7 +43,7 @@ curl:easy() ```Lua -- HTTP Post -curl:easy() +curl.easy() :setopt_url('http://posttestserver.com/post.php') :setopt_writefunction(io.write) :setopt_httppost(curl.form() -- lcurl guarantee that form will be alive @@ -71,7 +71,7 @@ local function get_bin_by(str,n) end end -curl:easy() +curl.easy() :setopt_url("ftp://moteus:123456@127.0.0.1/test.dat") :setopt_upload(true) :setopt_readfunction( @@ -85,19 +85,19 @@ curl:easy() -- Multi FTP Upload -- We get error E_LOGIN_DENIED for this operation -e1 = curl:easy() +e1 = curl.easy() :setopt_url("ftp://moteus:999999@127.0.0.1/test1.dat") :setopt_upload(true) :setopt_readfunction( function(t) return table.remove(t) end, {"1111", "2222"} ) -e2 = curl:easy() +e2 = curl.easy() :setopt_url("ftp://moteus:123456@127.0.0.1/test2.dat") :setopt_upload(true) :setopt_readfunction(get_bin_by(("e"):rep(1000), 5)) -m = curl:multi() +m = curl.multi() m:add_handle(e1) m:add_handle(e2) diff --git a/src/lchttppost.c b/src/lchttppost.c index 5baea7a..e45e393 100644 --- a/src/lchttppost.c +++ b/src/lchttppost.c @@ -106,7 +106,7 @@ static int lcurl_hpost_add_file(lua_State *L){ size_t name_len; const char *name = luaL_checklstring(L, 2, &name_len); const char *path = luaL_checkstring(L, 3); const char *type = 0, *fname = 0; - struct curl_slist *list; + struct curl_slist *list = NULL; struct curl_forms forms[3]; CURLFORMcode code; int i = 0; diff --git a/src/lcopteasy.h b/src/lcopteasy.h index 18e1e63..fb65b43 100644 --- a/src/lcopteasy.h +++ b/src/lcopteasy.h @@ -179,3 +179,20 @@ OPT_ENTRY( new_file_perms, NEW_FILE_PERMS, LNG, 0) OPT_ENTRY( new_directory_perms, NEW_DIRECTORY_PERMS, LNG, 0) OPT_ENTRY( telnetoptions, TELNETOPTIONS, LST, 0) + +OPT_ENTRY(sslcert, SSLCERT, STR, LCURL_STORE_STRING ) +OPT_ENTRY(sslcerttype, SSLCERTTYPE, STR, LCURL_STORE_STRING ) +OPT_ENTRY(sslengine, SSLENGINE, STR, LCURL_STORE_STRING ) +OPT_ENTRY(sslengine_default, SSLENGINE_DEFAULT, LNG, 0 ) +OPT_ENTRY(sslkey, SSLKEY, STR, LCURL_STORE_STRING ) +OPT_ENTRY(sslkeytype, SSLKEYTYPE, STR, LCURL_STORE_STRING ) +OPT_ENTRY(sslversion, SSLVERSION, LNG, 0 ) +OPT_ENTRY(ssl_cipher_list, SSL_CIPHER_LIST, STR, LCURL_STORE_STRING ) +// OPT_ENTRY(ssl_ctx_data, SSL_CTX_DATA, 0 ) //! @todo +// OPT_ENTRY(ssl_ctx_function, SSL_CTX_FUNCTION, 0 ) //! @todo +OPT_ENTRY(ssl_enable_alpn, SSL_ENABLE_ALPN, LNG, 0 ) +OPT_ENTRY(ssl_enable_npn, SSL_ENABLE_NPN, LNG, 0 ) +OPT_ENTRY(ssl_options, SSL_OPTIONS, LNG, 0 ) +OPT_ENTRY(ssl_sessionid_cache, SSL_SESSIONID_CACHE, LNG, 0 ) +OPT_ENTRY(ssl_verifyhost, SSL_VERIFYHOST, LNG, 0 ) +OPT_ENTRY(ssl_verifypeer, SSL_VERIFYPEER, LNG, 0 )