1616#include "lcshare.h"
1717#include "lcmulti.h"
1818#include "lcmime.h"
19+ #include "lcurlapi.h"
1920#include <memory.h>
2021
2122static const char * LCURL_ERROR_TAG = "LCURL_ERROR_TAG" ;
@@ -82,6 +83,9 @@ int lcurl_easy_create(lua_State *L, int error_mode){
8283 p -> multi = NULL ;
8384#if LCURL_CURL_VER_GE (7 ,56 ,0 )
8485 p -> mime = NULL ;
86+ #endif
87+ #if LCURL_CURL_VER_GE (7 ,63 ,0 )
88+ p -> url = NULL ;
8589#endif
8690 p -> storage = lcurl_storage_init (L );
8791 p -> wr .cb_ref = p -> wr .ud_ref = LUA_NOREF ;
@@ -151,6 +155,10 @@ static int lcurl_easy_cleanup(lua_State *L){
151155 p -> mime = NULL ;
152156#endif
153157
158+ #if LCURL_CURL_VER_GE (7 ,63 ,0 )
159+ p -> url = NULL ;
160+ #endif
161+
154162 if (p -> storage != LUA_NOREF ){
155163 p -> storage = lcurl_storage_free (L , p -> storage );
156164 }
@@ -539,6 +547,25 @@ static int lcurl_easy_set_MIMEPOST(lua_State *L){
539547
540548#endif
541549
550+ #if LCURL_CURL_VER_GE (7 ,63 ,0 )
551+
552+ static int lcurl_easy_set_CURLU (lua_State * L ) {
553+ lcurl_easy_t * p = lcurl_geteasy (L );
554+ lcurl_url_t * url = lcurl_geturl_at (L , 2 );
555+ CURLcode code = curl_easy_setopt (p -> curl , CURLOPT_CURLU , url -> url );
556+ if (code != CURLE_OK ) {
557+ return lcurl_fail_ex (L , p -> err_mode , LCURL_ERROR_EASY , code );
558+ }
559+
560+ lcurl_storage_preserve_iv (L , p -> storage , CURLOPT_CURLU , 2 );
561+
562+ p -> url = url ;
563+
564+ lua_settop (L , 1 );
565+ return 1 ;
566+ }
567+
568+ #endif
542569//}
543570
544571//{ unset
@@ -907,6 +934,25 @@ static int lcurl_easy_unset_MIMEPOST(lua_State *L){
907934
908935#endif
909936
937+ #if LCURL_CURL_VER_GE (7 ,63 ,0 )
938+
939+ static int lcurl_easy_unset_CURLU (lua_State * L ) {
940+ lcurl_easy_t * p = lcurl_geteasy (L );
941+ CURLcode code = curl_easy_setopt (p -> curl , CURLOPT_CURLU , NULL );
942+ if (code != CURLE_OK ) {
943+ return lcurl_fail_ex (L , p -> err_mode , LCURL_ERROR_EASY , code );
944+ }
945+
946+ lcurl_storage_remove_i (L , p -> storage , CURLOPT_CURLU );
947+
948+ p -> url = NULL ;
949+
950+ lua_settop (L , 1 );
951+ return 1 ;
952+ }
953+
954+ #endif
955+
910956//}
911957
912958//}
@@ -1731,6 +1777,9 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
17311777#if LCURL_CURL_VER_GE (7 ,56 ,0 )
17321778 OPT_ENTRY (mimepost , MIMEPOST , TTT , 0 , 0 )
17331779#endif
1780+ #if LCURL_CURL_VER_GE (7 ,63 ,0 )
1781+ OPT_ENTRY (curlu , CURLU , TTT , 0 , 0 )
1782+ #endif
17341783#undef OPT_ENTRY
17351784
17361785#define OPT_ENTRY (L , N , T , S , D ) { "unsetopt_" #L , lcurl_easy_unset_ ##N },
@@ -1756,6 +1805,9 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
17561805#if LCURL_CURL_VER_GE (7 ,56 ,0 )
17571806 OPT_ENTRY (mimepost , MIMEPOST , TTT , 0 , 0 )
17581807#endif
1808+ #if LCURL_CURL_VER_GE (7 ,63 ,0 )
1809+ OPT_ENTRY (curlu , CURLU , TTT , 0 , 0 )
1810+ #endif
17591811#undef OPT_ENTRY
17601812
17611813#define OPT_ENTRY (L , N , T , S ) { "getinfo_" #L , lcurl_easy_get_ ##N },
@@ -1813,6 +1865,9 @@ static const lcurl_const_t lcurl_easy_opt[] = {
18131865#if LCURL_CURL_VER_GE (7 ,56 ,0 )
18141866 OPT_ENTRY (mimepost , MIMEPOST , TTT , 0 , 0 )
18151867#endif
1868+ #if LCURL_CURL_VER_GE (7 ,63 ,0 )
1869+ OPT_ENTRY (curlu , CURLU , TTT , 0 , 0 )
1870+ #endif
18161871#undef OPT_ENTRY
18171872#undef FLG_ENTRY
18181873
0 commit comments