Skip to content

Commit 30b9cb2

Browse files
committed
Add. Support cURL 7.48.0
1 parent 3055e1d commit 30b9cb2

File tree

6 files changed

+177
-12
lines changed

6 files changed

+177
-12
lines changed

src/lceasy.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,33 @@ static int lcurl_easy_set_SHARE(lua_State *L){
336336
lua_settop(L, 1);
337337
return 1;
338338
}
339+
340+
#if LCURL_CURL_VER_GE(7,46,0)
341+
342+
static int lcurl_easy_set_STREAM_DEPENDS_impl(lua_State *L, int opt){
343+
lcurl_easy_t *p = lcurl_geteasy(L);
344+
lcurl_easy_t *e = lcurl_geteasy_at(L, 2);
345+
CURLcode code = curl_easy_setopt(p->curl, opt, e->curl);
346+
if(code != CURLE_OK){
347+
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
348+
}
349+
350+
lcurl_storage_preserve_iv(L, p->storage, opt, 2);
351+
352+
lua_settop(L, 1);
353+
return 1;
354+
}
355+
356+
static int lcurl_easy_set_STREAM_DEPENDS(lua_State *L){
357+
return lcurl_easy_set_STREAM_DEPENDS_impl(L, CURLOPT_STREAM_DEPENDS);
358+
}
359+
360+
static int lcurl_easy_set_STREAM_DEPENDS_E(lua_State *L){
361+
return lcurl_easy_set_STREAM_DEPENDS_impl(L, CURLOPT_STREAM_DEPENDS_E);
362+
}
363+
364+
#endif
365+
339366
//}
340367

341368
//{ unset
@@ -522,6 +549,38 @@ static int lcurl_easy_unset_POSTFIELDS(lua_State *L){
522549
return 1;
523550
}
524551

552+
#if LCURL_CURL_VER_GE(7,46,0)
553+
554+
static int lcurl_easy_unset_STREAM_DEPENDS(lua_State *L){
555+
lcurl_easy_t *p = lcurl_geteasy(L);
556+
557+
CURLcode code = curl_easy_setopt(p->curl, CURLOPT_STREAM_DEPENDS, NULL);
558+
if(code != CURLE_OK){
559+
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
560+
}
561+
562+
lcurl_storage_remove_i(L, p->storage, CURLOPT_STREAM_DEPENDS);
563+
564+
lua_settop(L, 1);
565+
return 1;
566+
}
567+
568+
static int lcurl_easy_unset_STREAM_DEPENDS_E(lua_State *L){
569+
lcurl_easy_t *p = lcurl_geteasy(L);
570+
571+
CURLcode code = curl_easy_setopt(p->curl, CURLOPT_STREAM_DEPENDS_E, NULL);
572+
if(code != CURLE_OK){
573+
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
574+
}
575+
576+
lcurl_storage_remove_i(L, p->storage, CURLOPT_STREAM_DEPENDS_E);
577+
578+
lua_settop(L, 1);
579+
return 1;
580+
}
581+
582+
#endif
583+
525584
//}
526585

527586
//}
@@ -907,6 +966,10 @@ static int lcurl_easy_setopt(lua_State *L){
907966
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
908967
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
909968
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
969+
#if LCURL_CURL_VER_GE(7,46,0)
970+
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
971+
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
972+
#endif
910973
}
911974
#undef OPT_ENTRY
912975

@@ -930,6 +993,10 @@ static int lcurl_easy_unsetopt(lua_State *L){
930993
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
931994
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
932995
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
996+
#if LCURL_CURL_VER_GE(7,46,0)
997+
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
998+
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
999+
#endif
9331000
}
9341001
#undef OPT_ENTRY
9351002

@@ -990,6 +1057,10 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
9901057
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
9911058
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
9921059
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
1060+
#if LCURL_CURL_VER_GE(7,46,0)
1061+
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
1062+
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
1063+
#endif
9931064
#undef OPT_ENTRY
9941065

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

10061081
#define OPT_ENTRY(L, N, T, S) { "getinfo_"#L, lcurl_easy_get_##N },
@@ -1036,6 +1111,10 @@ static const lcurl_const_t lcurl_easy_opt[] = {
10361111
OPT_ENTRY(readfunction, READFUNCTION, TTT, 0, 0)
10371112
OPT_ENTRY(headerfunction, HEADERFUNCTION, TTT, 0, 0)
10381113
OPT_ENTRY(progressfunction, PROGRESSFUNCTION, TTT, 0, 0)
1114+
#if LCURL_CURL_VER_GE(7,46,0)
1115+
OPT_ENTRY(stream_depends, STREAM_DEPENDS, TTT, 0, 0)
1116+
OPT_ENTRY(stream_depends_e, STREAM_DEPENDS_E, TTT, 0, 0)
1117+
#endif
10391118
#undef OPT_ENTRY
10401119
#undef FLG_ENTRY
10411120

src/lcerr_easy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,9 @@ ERR_ENTRY ( HTTP2 )
112112
#else
113113
ERR_ENTRY ( OBSOLETE16 )
114114
#endif
115+
#if LCURL_CURL_VER_GE(7,39,0)
116+
ERR_ENTRY ( SSL_PINNEDPUBKEYNOTMATCH )
117+
#endif
118+
#if LCURL_CURL_VER_GE(7,41,0)
119+
ERR_ENTRY ( SSL_INVALIDCERTSTATUS )
120+
#endif

src/lcflags.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@ FLG_ENTRY(USESSL_NONE )
5959
FLG_ENTRY(USESSL_TRY )
6060
FLG_ENTRY(USESSL_CONTROL )
6161
FLG_ENTRY(USESSL_ALL )
62+
63+
/* Definition of bits for the CURLOPT_SSL_OPTIONS argument: */
6264
#ifdef CURLSSLOPT_ALLOW_BEAST
6365
FLG_ENTRY(SSLOPT_ALLOW_BEAST )
6466
#endif
67+
#ifdef CURLSSLOPT_NO_REVOKE
68+
FLG_ENTRY(SSLOPT_NO_REVOKE )
69+
#endif
6570

6671
/* parameter for the CURLOPT_FTP_SSL_CCC option */
6772
FLG_ENTRY(FTPSSL_CCC_NONE )
@@ -146,6 +151,12 @@ FLG_ENTRY(PROTO_RTMPTS )
146151
#ifdef CURLPROTO_GOPHER
147152
FLG_ENTRY(PROTO_GOPHER )
148153
#endif
154+
#ifdef CURLPROTO_SMB
155+
FLG_ENTRY(PROTO_SMB )
156+
#endif
157+
#ifdef CURLPROTO_SMBS
158+
FLG_ENTRY(PROTO_SMBS )
159+
#endif
149160
FLG_ENTRY(PROTO_ALL )
150161

151162
FLG_ENTRY(PROXY_HTTP ) /* added in 7.10.0 */

src/lchttppost.c

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@
1616
#define LCURL_HTTPPOST_NAME LCURL_PREFIX" HTTPPost"
1717
static const char *LCURL_HTTPPOST = LCURL_HTTPPOST_NAME;
1818

19+
20+
#if LUA_VERSION_NUM >= 503 /* Lua 5.3 */
21+
22+
/*! @fixme detect real types (e.g. float/int32_t) */
23+
24+
# define LCURL_USE_INTEGER
25+
26+
#endif
27+
28+
#ifdef LCURL_USE_INTEGER
29+
# ifdef LUA_32BITS
30+
# define LCURL_INT_SIZE_16
31+
# define LCURL_INT_SIZE_32
32+
# else
33+
# define LCURL_INT_SIZE_16
34+
# define LCURL_INT_SIZE_32
35+
# define LCURL_INT_SIZE_64
36+
# endif
37+
#endif
38+
39+
#if LCURL_CURL_VER_GE(7,46,0)
40+
# define LCURL_FORM_CONTENTLEN CURLFORM_CONTENTLEN
41+
# define LCURL_LEN_TYPE curl_off_t
42+
#else
43+
# define LCURL_FORM_CONTENTLEN CURLFORM_CONTENTSLENGTH
44+
# define LCURL_LEN_TYPE long
45+
#endif
46+
1947
//{ stream
2048

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

106134
code = curl_formadd(&p->post, &p->last,
107-
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
108-
CURLFORM_PTRCONTENTS, cont, CURLFORM_CONTENTSLENGTH, cont_len,
135+
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
136+
CURLFORM_PTRCONTENTS, cont, LCURL_FORM_CONTENTLEN, (LCURL_LEN_TYPE)cont_len,
109137
CURLFORM_ARRAY, forms,
110138
CURLFORM_END);
111139

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

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

204232
code = curl_formadd(&p->post, &p->last,
205-
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
233+
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
206234
CURLFORM_FILE, path,
207235
CURLFORM_ARRAY, forms,
208236
CURLFORM_END);
@@ -234,7 +262,6 @@ static int lcurl_hpost_add_stream(lua_State *L){
234262
int n = 0, i = 3;
235263
struct curl_forms forms[4];
236264

237-
238265
while(1){ // [filename, [type,]] [headers,]
239266
if(lua_isnone(L, i)){
240267
lua_pushliteral(L, "stream size required");
@@ -265,7 +292,12 @@ static int lcurl_hpost_add_stream(lua_State *L){
265292
}
266293
++i;
267294
}
295+
296+
#if defined(LCURL_INT_SIZE_64) && LCURL_CURL_VER_GE(7,46,0)
297+
len = luaL_checinteger(L, i);
298+
#else
268299
len = luaL_checklong(L, i);
300+
#endif
269301

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

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

292324
code = curl_formadd(&p->post, &p->last,
293-
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
294-
CURLFORM_STREAM, stream, CURLFORM_CONTENTSLENGTH, len,
325+
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
326+
CURLFORM_STREAM, stream, LCURL_FORM_CONTENTLEN, (LCURL_LEN_TYPE)len,
295327
CURLFORM_ARRAY, forms,
296328
CURLFORM_END
297329
);
@@ -383,7 +415,7 @@ static int lcurl_hpost_add_files(lua_State *L){
383415
}
384416

385417
code = curl_formadd(&p->post, &p->last,
386-
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, name_len,
418+
CURLFORM_PTRNAME, name, CURLFORM_NAMELENGTH, (long)name_len,
387419
CURLFORM_ARRAY, forms,
388420
CURLFORM_END);
389421

src/lcopteasy.h

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#undef TCP_KEEPALIVE
55

66
/* Before version 7.17.0, strings were not copied.
7-
Instead the user was forced keep them available
7+
Instead the user was forced keep them available
88
until libcurl no longer needed them.
99
*/
1010

@@ -232,14 +232,13 @@ OPT_ENTRY( ssl_cipher_list, SSL_CIPHER_LIST, STR, LCURL_STORE_ST
232232
OPT_ENTRY( ssl_enable_alpn, SSL_ENABLE_ALPN, LNG, 0, 1 )
233233
OPT_ENTRY( ssl_enable_npn, SSL_ENABLE_NPN, LNG, 0, 1 )
234234
#endif
235-
#if LCURL_CURL_VER_GE(7,25,0)
235+
#if LCURL_CURL_VER_GE(7,25,0)
236236
OPT_ENTRY( ssl_options, SSL_OPTIONS, LNG, 0, LCURL_DEFAULT_VALUE )
237237
#endif
238238
OPT_ENTRY( ssl_sessionid_cache, SSL_SESSIONID_CACHE, LNG, 0, 1 )
239239
OPT_ENTRY( ssl_verifyhost, SSL_VERIFYHOST, LNG, 0, 2 )
240240
OPT_ENTRY( ssl_verifypeer, SSL_VERIFYPEER, LNG, 0, 1 )
241241

242-
243242
FLG_ENTRY( SSLVERSION_DEFAULT )
244243
FLG_ENTRY( SSLVERSION_TLSv1 )
245244
FLG_ENTRY( SSLVERSION_SSLv2 )
@@ -260,6 +259,12 @@ FLG_ENTRY( HTTP_VERSION_1_1 )
260259
#if LCURL_CURL_VER_GE(7,33,0)
261260
FLG_ENTRY( HTTP_VERSION_2_0 )
262261
#endif
262+
#if LCURL_CURL_VER_GE(7,43,0)
263+
FLG_ENTRY( HTTP_VERSION_2 )
264+
#endif
265+
#if LCURL_CURL_VER_GE(7,47,0)
266+
FLG_ENTRY( HTTP_VERSION_2TLS )
267+
#endif
263268

264269
FLG_ENTRY( READFUNC_PAUSE ) /*7.18.0*/
265270
FLG_ENTRY( WRITEFUNC_PAUSE ) /*7.18.0*/
@@ -275,6 +280,38 @@ FLG_ENTRY( CSELECT_ERR ) /*7.16.3*/
275280
FLG_ENTRY( CSELECT_IN ) /*7.16.3*/
276281
FLG_ENTRY( CSELECT_OUT ) /*7.16.3*/
277282

283+
FLG_ENTRY( IPRESOLVE_WHATEVER ) /*7.10.8*/
284+
FLG_ENTRY( IPRESOLVE_V4 ) /*7.10.8*/
285+
FLG_ENTRY( IPRESOLVE_V6 ) /*7.10.8*/
286+
287+
#if LCURL_CURL_VER_GE(7,39,0)
288+
OPT_ENTRY( pinnedpublickey, PINNEDPUBLICKEY, STR, 0, LCURL_DEFAULT_VALUE )
289+
#endif
290+
#if LCURL_CURL_VER_GE(7,40,0)
291+
OPT_ENTRY( unix_socket_path, UNIX_SOCKET_PATH, STR, 0, LCURL_DEFAULT_VALUE )
292+
#endif
293+
#if LCURL_CURL_VER_GE(7,41,0)
294+
OPT_ENTRY( ssl_verifystatus, SSL_VERIFYSTATUS, LNG, 0, LCURL_DEFAULT_VALUE )
295+
#endif
296+
#if LCURL_CURL_VER_GE(7,42,0)
297+
OPT_ENTRY( ssl_falsestart, SSL_FALSESTART, LNG, 0, LCURL_DEFAULT_VALUE )
298+
OPT_ENTRY( path_as_is, PATH_AS_IS, LNG, 0, LCURL_DEFAULT_VALUE )
299+
#endif
300+
#if LCURL_CURL_VER_GE(7,43,0)
301+
OPT_ENTRY( proxy_service_name, PROXY_SERVICE_NAME, STR, 0, LCURL_DEFAULT_VALUE )
302+
OPT_ENTRY( service_name, SERVICE_NAME, STR, 0, LCURL_DEFAULT_VALUE )
303+
OPT_ENTRY( pipewait, PIPEWAIT, LNG, 0, LCURL_DEFAULT_VALUE )
304+
#endif
305+
#if LCURL_CURL_VER_GE(7,45,0)
306+
OPT_ENTRY( default_protocol, DEFAULT_PROTOCOL, STR, 0, LCURL_DEFAULT_VALUE )
307+
#endif
308+
#if LCURL_CURL_VER_GE(7,46,0)
309+
OPT_ENTRY( stream_weight, STREAM_WEIGHT, LNG, 0, LCURL_DEFAULT_VALUE )
310+
#endif
311+
#if LCURL_CURL_VER_GE(7,48,0)
312+
OPT_ENTRY( tftp_no_options, TFTP_NO_OPTIONS, LNG, 0, LCURL_DEFAULT_VALUE )
313+
#endif
314+
278315
#ifdef OPT_ENTRY_IS_NULL
279316
# undef OPT_ENTRY
280317
#endif

test/test_easy.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ local _ENV = TEST_CASE'setopt_user_data' if ENABLE then
923923

924924
local c
925925

926-
function setup()
926+
function teardown()
927927
if c then c:close() end
928928
c = nil
929929
end

0 commit comments

Comments
 (0)