Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions src/lceasy.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,33 @@ static int lcurl_easy_set_SHARE(lua_State *L){
lua_settop(L, 1);
return 1;
}

#if LCURL_CURL_VER_GE(7,46,0)

static int lcurl_easy_set_STREAM_DEPENDS_impl(lua_State *L, int opt){
lcurl_easy_t *p = lcurl_geteasy(L);
lcurl_easy_t *e = lcurl_geteasy_at(L, 2);
CURLcode code = curl_easy_setopt(p->curl, opt, e->curl);
if(code != CURLE_OK){
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
}

lcurl_storage_preserve_iv(L, p->storage, opt, 2);

lua_settop(L, 1);
return 1;
}

static int lcurl_easy_set_STREAM_DEPENDS(lua_State *L){
return lcurl_easy_set_STREAM_DEPENDS_impl(L, CURLOPT_STREAM_DEPENDS);
}

static int lcurl_easy_set_STREAM_DEPENDS_E(lua_State *L){
return lcurl_easy_set_STREAM_DEPENDS_impl(L, CURLOPT_STREAM_DEPENDS_E);
}

#endif

//}

//{ unset
Expand Down Expand Up @@ -522,6 +549,38 @@ static int lcurl_easy_unset_POSTFIELDS(lua_State *L){
return 1;
}

#if LCURL_CURL_VER_GE(7,46,0)

static int lcurl_easy_unset_STREAM_DEPENDS(lua_State *L){
lcurl_easy_t *p = lcurl_geteasy(L);

CURLcode code = curl_easy_setopt(p->curl, CURLOPT_STREAM_DEPENDS, NULL);
if(code != CURLE_OK){
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
}

lcurl_storage_remove_i(L, p->storage, CURLOPT_STREAM_DEPENDS);

lua_settop(L, 1);
return 1;
}

static int lcurl_easy_unset_STREAM_DEPENDS_E(lua_State *L){
lcurl_easy_t *p = lcurl_geteasy(L);

CURLcode code = curl_easy_setopt(p->curl, CURLOPT_STREAM_DEPENDS_E, NULL);
if(code != CURLE_OK){
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
}

lcurl_storage_remove_i(L, p->storage, CURLOPT_STREAM_DEPENDS_E);

lua_settop(L, 1);
return 1;
}

#endif

//}

//}
Expand Down Expand Up @@ -907,6 +966,10 @@ static int lcurl_easy_setopt(lua_State *L){
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
#if LCURL_CURL_VER_GE(7,46,0)
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
#endif
}
#undef OPT_ENTRY

Expand All @@ -930,6 +993,10 @@ static int lcurl_easy_unsetopt(lua_State *L){
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
#if LCURL_CURL_VER_GE(7,46,0)
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
#endif
}
#undef OPT_ENTRY

Expand Down Expand Up @@ -990,6 +1057,10 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
#if LCURL_CURL_VER_GE(7,46,0)
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
#endif
#undef OPT_ENTRY

#define OPT_ENTRY(L, N, T, S, D) { "unsetopt_"#L, lcurl_easy_unset_##N },
Expand All @@ -1001,6 +1072,10 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
#if LCURL_CURL_VER_GE(7,46,0)
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
#endif
#undef OPT_ENTRY

#define OPT_ENTRY(L, N, T, S) { "getinfo_"#L, lcurl_easy_get_##N },
Expand Down Expand Up @@ -1036,6 +1111,10 @@ static const lcurl_const_t lcurl_easy_opt[] = {
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
#if LCURL_CURL_VER_GE(7,46,0)
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
#endif
#undef OPT_ENTRY
#undef FLG_ENTRY

Expand Down
6 changes: 6 additions & 0 deletions src/lcerr_easy.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ ERR_ENTRY ( HTTP2 )
#else
ERR_ENTRY ( OBSOLETE16 )
#endif
#if LCURL_CURL_VER_GE(7,39,0)
ERR_ENTRY ( SSL_PINNEDPUBKEYNOTMATCH )
#endif
#if LCURL_CURL_VER_GE(7,41,0)
ERR_ENTRY ( SSL_INVALIDCERTSTATUS )
#endif
11 changes: 11 additions & 0 deletions src/lcflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ FLG_ENTRY(USESSL_NONE )
FLG_ENTRY(USESSL_TRY )
FLG_ENTRY(USESSL_CONTROL )
FLG_ENTRY(USESSL_ALL )

/* Definition of bits for the CURLOPT_SSL_OPTIONS argument: */
#ifdef CURLSSLOPT_ALLOW_BEAST
FLG_ENTRY(SSLOPT_ALLOW_BEAST )
#endif
#ifdef CURLSSLOPT_NO_REVOKE
FLG_ENTRY(SSLOPT_NO_REVOKE )
#endif

/* parameter for the CURLOPT_FTP_SSL_CCC option */
FLG_ENTRY(FTPSSL_CCC_NONE )
Expand Down Expand Up @@ -146,6 +151,12 @@ FLG_ENTRY(PROTO_RTMPTS )
#ifdef CURLPROTO_GOPHER
FLG_ENTRY(PROTO_GOPHER )
#endif
#ifdef CURLPROTO_SMB
FLG_ENTRY(PROTO_SMB )
#endif
#ifdef CURLPROTO_SMBS
FLG_ENTRY(PROTO_SMBS )
#endif
FLG_ENTRY(PROTO_ALL )

FLG_ENTRY(PROXY_HTTP ) /* added in 7.10.0 */
Expand Down
48 changes: 40 additions & 8 deletions src/lchttppost.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,34 @@
#define LCURL_HTTPPOST_NAME LCURL_PREFIX" HTTPPost"
static const char *LCURL_HTTPPOST = LCURL_HTTPPOST_NAME;


#if LUA_VERSION_NUM >= 503 /* Lua 5.3 */

/*! @fixme detect real types (e.g. float/int32_t) */

# define LCURL_USE_INTEGER

#endif

#ifdef LCURL_USE_INTEGER
# ifdef LUA_32BITS
# define LCURL_INT_SIZE_16
# define LCURL_INT_SIZE_32
# else
# define LCURL_INT_SIZE_16
# define LCURL_INT_SIZE_32
# define LCURL_INT_SIZE_64
# endif
#endif

#if LCURL_CURL_VER_GE(7,46,0)
# define LCURL_FORM_CONTENTLEN CURLFORM_CONTENTLEN
# define LCURL_LEN_TYPE curl_off_t
#else
# define LCURL_FORM_CONTENTLEN CURLFORM_CONTENTSLENGTH
# define LCURL_LEN_TYPE long
#endif

//{ stream

static lcurl_hpost_stream_t *lcurl_hpost_stream_add(lua_State *L, lcurl_hpost_t *p){
Expand Down Expand Up @@ -104,8 +132,8 @@ static int lcurl_hpost_add_content(lua_State *L){
forms[i].option = CURLFORM_END;

code = curl_formadd(&p->post, &p->last,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
CURLFORM_PTRCONTENTS, cont, CURLFORM_CONTENTSLENGTH, cont_len,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
CURLFORM_PTRCONTENTS, cont, LCURL_FORM_CONTENTLEN, (LCURL_LEN_TYPE)cont_len,
CURLFORM_ARRAY, forms,
CURLFORM_END);

Expand Down Expand Up @@ -139,7 +167,7 @@ static int lcurl_hpost_add_buffer(lua_State *L){
forms[i].option = CURLFORM_END;

code = curl_formadd(&p->post, &p->last,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
CURLFORM_BUFFER, buff,
CURLFORM_BUFFERPTR, cont, CURLFORM_BUFFERLENGTH, cont_len,
CURLFORM_ARRAY, forms,
Expand Down Expand Up @@ -202,7 +230,7 @@ static int lcurl_hpost_add_file(lua_State *L){
forms[i].option = CURLFORM_END;

code = curl_formadd(&p->post, &p->last,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
CURLFORM_FILE, path,
CURLFORM_ARRAY, forms,
CURLFORM_END);
Expand Down Expand Up @@ -234,7 +262,6 @@ static int lcurl_hpost_add_stream(lua_State *L){
int n = 0, i = 3;
struct curl_forms forms[4];


while(1){ // [filename, [type,]] [headers,]
if(lua_isnone(L, i)){
lua_pushliteral(L, "stream size required");
Expand Down Expand Up @@ -265,7 +292,12 @@ static int lcurl_hpost_add_stream(lua_State *L){
}
++i;
}

#if defined(LCURL_INT_SIZE_64) && LCURL_CURL_VER_GE(7,46,0)
len = luaL_checinteger(L, i);
#else
len = luaL_checklong(L, i);
#endif

lcurl_set_callback(L, &rd, i + 1, "read");

Expand All @@ -290,8 +322,8 @@ static int lcurl_hpost_add_stream(lua_State *L){
stream->rd = rd;

code = curl_formadd(&p->post, &p->last,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
CURLFORM_STREAM, stream, CURLFORM_CONTENTSLENGTH, len,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
CURLFORM_STREAM, stream, LCURL_FORM_CONTENTLEN, (LCURL_LEN_TYPE)len,
CURLFORM_ARRAY, forms,
CURLFORM_END
);
Expand Down Expand Up @@ -383,7 +415,7 @@ static int lcurl_hpost_add_files(lua_State *L){
}

code = curl_formadd(&p->post, &p->last,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
CURLFORM_ARRAY, forms,
CURLFORM_END);

Expand Down
43 changes: 40 additions & 3 deletions src/lcopteasy.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#undef TCP_KEEPALIVE

/* Before version 7.17.0, strings were not copied.
Instead the user was forced keep them available
Instead the user was forced keep them available
until libcurl no longer needed them.
*/

Expand Down Expand Up @@ -232,14 +232,13 @@ OPT_ENTRY( ssl_cipher_list, SSL_CIPHER_LIST, STR, LCURL_STORE_ST
OPT_ENTRY( ssl_enable_alpn, SSL_ENABLE_ALPN, LNG, 0, 1 )
OPT_ENTRY( ssl_enable_npn, SSL_ENABLE_NPN, LNG, 0, 1 )
#endif
#if LCURL_CURL_VER_GE(7,25,0)
#if LCURL_CURL_VER_GE(7,25,0)
OPT_ENTRY( ssl_options, SSL_OPTIONS, LNG, 0, LCURL_DEFAULT_VALUE )
#endif
OPT_ENTRY( ssl_sessionid_cache, SSL_SESSIONID_CACHE, LNG, 0, 1 )
OPT_ENTRY( ssl_verifyhost, SSL_VERIFYHOST, LNG, 0, 2 )
OPT_ENTRY( ssl_verifypeer, SSL_VERIFYPEER, LNG, 0, 1 )


FLG_ENTRY( SSLVERSION_DEFAULT )
FLG_ENTRY( SSLVERSION_TLSv1 )
FLG_ENTRY( SSLVERSION_SSLv2 )
Expand All @@ -260,6 +259,12 @@ FLG_ENTRY( HTTP_VERSION_1_1 )
#if LCURL_CURL_VER_GE(7,33,0)
FLG_ENTRY( HTTP_VERSION_2_0 )
#endif
#if LCURL_CURL_VER_GE(7,43,0)
FLG_ENTRY( HTTP_VERSION_2 )
#endif
#if LCURL_CURL_VER_GE(7,47,0)
FLG_ENTRY( HTTP_VERSION_2TLS )
#endif

FLG_ENTRY( READFUNC_PAUSE ) /*7.18.0*/
FLG_ENTRY( WRITEFUNC_PAUSE ) /*7.18.0*/
Expand All @@ -275,6 +280,38 @@ FLG_ENTRY( CSELECT_ERR ) /*7.16.3*/
FLG_ENTRY( CSELECT_IN ) /*7.16.3*/
FLG_ENTRY( CSELECT_OUT ) /*7.16.3*/

FLG_ENTRY( IPRESOLVE_WHATEVER ) /*7.10.8*/
FLG_ENTRY( IPRESOLVE_V4 ) /*7.10.8*/
FLG_ENTRY( IPRESOLVE_V6 ) /*7.10.8*/

#if LCURL_CURL_VER_GE(7,39,0)
OPT_ENTRY( pinnedpublickey, PINNEDPUBLICKEY, STR, 0, LCURL_DEFAULT_VALUE )
#endif
#if LCURL_CURL_VER_GE(7,40,0)
OPT_ENTRY( unix_socket_path, UNIX_SOCKET_PATH, STR, 0, LCURL_DEFAULT_VALUE )
#endif
#if LCURL_CURL_VER_GE(7,41,0)
OPT_ENTRY( ssl_verifystatus, SSL_VERIFYSTATUS, LNG, 0, LCURL_DEFAULT_VALUE )
#endif
#if LCURL_CURL_VER_GE(7,42,0)
OPT_ENTRY( ssl_falsestart, SSL_FALSESTART, LNG, 0, LCURL_DEFAULT_VALUE )
OPT_ENTRY( path_as_is, PATH_AS_IS, LNG, 0, LCURL_DEFAULT_VALUE )
#endif
#if LCURL_CURL_VER_GE(7,43,0)
OPT_ENTRY( proxy_service_name, PROXY_SERVICE_NAME, STR, 0, LCURL_DEFAULT_VALUE )
OPT_ENTRY( service_name, SERVICE_NAME, STR, 0, LCURL_DEFAULT_VALUE )
OPT_ENTRY( pipewait, PIPEWAIT, LNG, 0, LCURL_DEFAULT_VALUE )
#endif
#if LCURL_CURL_VER_GE(7,45,0)
OPT_ENTRY( default_protocol, DEFAULT_PROTOCOL, STR, 0, LCURL_DEFAULT_VALUE )
#endif
#if LCURL_CURL_VER_GE(7,46,0)
OPT_ENTRY( stream_weight, STREAM_WEIGHT, LNG, 0, LCURL_DEFAULT_VALUE )
#endif
#if LCURL_CURL_VER_GE(7,48,0)
OPT_ENTRY( tftp_no_options, TFTP_NO_OPTIONS, LNG, 0, LCURL_DEFAULT_VALUE )
#endif

#ifdef OPT_ENTRY_IS_NULL
# undef OPT_ENTRY
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/test_easy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ local _ENV = TEST_CASE'setopt_user_data' if ENABLE then

local c

function setup()
function teardown()
if c then c:close() end
c = nil
end
Expand Down