Skip to content

Commit 1a44488

Browse files
committed
Add. happy_eyeballs_timeout_ms and timevalue_large options
1 parent 7b13a8c commit 1a44488

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

src/lceasy.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,25 @@ static int lcurl_opt_set_long_(lua_State *L, int opt){
323323
return 1;
324324
}
325325

326+
#if LCURL_CURL_VER_GE(7,59,0)
327+
328+
static int lcurl_opt_set_off_(lua_State *L, int opt){
329+
lcurl_easy_t *p = lcurl_geteasy(L);
330+
curl_off_t val; CURLcode code;
331+
332+
luaL_argcheck(L, lua_type(L, 2) == LUA_TNUMBER, 2, "number expected");
333+
val = lutil_checkint64(L, 2);
334+
335+
code = curl_easy_setopt(p->curl, opt, val);
336+
if(code != CURLE_OK){
337+
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
338+
}
339+
lua_settop(L, 1);
340+
return 1;
341+
}
342+
343+
#endif
344+
326345
static int lcurl_opt_set_string_(lua_State *L, int opt, int store){
327346
lcurl_easy_t *p = lcurl_geteasy(L);
328347
CURLcode code;
@@ -378,6 +397,10 @@ static int lcurl_opt_set_slist_(lua_State *L, int opt, int list_no){
378397
return lcurl_opt_set_long_(L, CURLOPT_##N);\
379398
}
380399

400+
#define LCURL_OFF_OPT(N, S) static int lcurl_easy_set_##N(lua_State *L){\
401+
return lcurl_opt_set_off_(L, CURLOPT_##N);\
402+
}
403+
381404
#define OPT_ENTRY(L, N, T, S, D) LCURL_##T##_OPT(N, S)
382405

383406
#include "lcopteasy.h"
@@ -409,6 +432,7 @@ static int lcurl_easy_set_POSTFIELDS(lua_State *L){
409432
#undef LCURL_STR_OPT
410433
#undef LCURL_LST_OPT
411434
#undef LCURL_LNG_OPT
435+
#undef LCURL_OFF_OPT
412436

413437
static size_t lcurl_hpost_read_callback(char *buffer, size_t size, size_t nitems, void *arg);
414438

@@ -508,6 +532,22 @@ static int lcurl_opt_unset_long_(lua_State *L, int opt, long val){
508532
return 1;
509533
}
510534

535+
#if LCURL_CURL_VER_GE(7,59,0)
536+
537+
static int lcurl_opt_unset_off_(lua_State *L, int opt, curl_off_t val){
538+
lcurl_easy_t *p = lcurl_geteasy(L);
539+
CURLcode code;
540+
541+
code = curl_easy_setopt(p->curl, opt, val);
542+
if(code != CURLE_OK){
543+
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
544+
}
545+
lua_settop(L, 1);
546+
return 1;
547+
}
548+
549+
#endif
550+
511551
static int lcurl_opt_unset_string_(lua_State *L, int opt, const char *val){
512552
lcurl_easy_t *p = lcurl_geteasy(L);
513553
CURLcode code;
@@ -556,6 +596,10 @@ static int lcurl_opt_unset_slist_(lua_State *L, int opt, int list_no){
556596
return lcurl_opt_unset_long_(L, CURLOPT_##N, (D));\
557597
}
558598

599+
#define LCURL_OFF_OPT(N, S, D) static int lcurl_easy_unset_##N(lua_State *L){\
600+
return lcurl_opt_unset_off_(L, CURLOPT_##N, (D));\
601+
}
602+
559603
#define OPT_ENTRY(L, N, T, S, D) LCURL_##T##_OPT(N, S, D)
560604

561605
#include "lcopteasy.h"
@@ -565,6 +609,7 @@ static int lcurl_opt_unset_slist_(lua_State *L, int opt, int list_no){
565609
#undef LCURL_STR_OPT
566610
#undef LCURL_LST_OPT
567611
#undef LCURL_LNG_OPT
612+
#undef LCURL_OFF_OPT
568613

569614
static int lcurl_easy_unset_HTTPPOST(lua_State *L){
570615
lcurl_easy_t *p = lcurl_geteasy(L);

src/lceasy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define LCURL_LST_INDEX(N) LCURL_##N##_LIST,
1919
#define LCURL_STR_INDEX(N)
2020
#define LCURL_LNG_INDEX(N)
21+
#define LCURL_OFF_INDEX(N)
2122
#define OPT_ENTRY(L, N, T, S, D) LCURL_##T##_INDEX(N)
2223

2324
enum {
@@ -28,6 +29,7 @@ enum {
2829
LCURL_LIST_COUNT,
2930
};
3031

32+
#undef LCURL_OFF_INDEX
3133
#undef LCURL_LST_INDEX
3234
#undef LCURL_STR_INDEX
3335
#undef LCURL_LNG_INDEX

src/lcopteasy.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ OPT_ENTRY( socks5_auth, SOCKS5_AUTH, LNG, 0, LCURL_DEF
405405
OPT_ENTRY( ssh_compression, SSH_COMPRESSION, LNG, 0, LCURL_DEFAULT_VALUE)
406406
#endif
407407

408+
#if LCURL_CURL_VER_GE(7,59,0)
409+
OPT_ENTRY( happy_eyeballs_timeout_ms,HAPPY_EYEBALLS_TIMEOUT_MS,LNG, 0, CURL_HET_DEFAULT)
410+
OPT_ENTRY( timevalue_large, TIMEVALUE_LARGE ,OFF, 0, LCURL_DEFAULT_VALUE)
411+
#endif
412+
408413
#ifdef LCURL__TCP_FASTOPEN
409414
# define TCP_FASTOPEN LCURL__TCP_FASTOPEN
410415
# undef LCURL__TCP_FASTOPEN

0 commit comments

Comments
 (0)