From: Patrick Monnerat Date: Tue, 15 Nov 2022 16:50:22 +0000 (+0100) Subject: configure, cmake, lib: more form api deprecation X-Git-Tag: curl-8_3_0~272 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=038c46f61fdbc1b8a3b66dd5546fbd3c30b0b2db;p=thirdparty%2Fcurl.git configure, cmake, lib: more form api deprecation Introduce a --enable-form-api configure option to control its inclusion in builds. The condition name defined for it is CURL_DISABLE_FORM_API. Form api code is dependent of MIME: configure and CMake handle this dependency automatically: CMake by making it a dependent option explicitly, configure by inheriting the MIME value by default and rejecting explicit incompatible values. "form-api" is now a new hidden test feature. Update libcurl modules to respect this option and adjust tests accordingly. Closes #9621 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0327bfb3f7..07e51849f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,6 +199,9 @@ option(CURL_DISABLE_DOH "disables DNS-over-HTTPS" OFF) mark_as_advanced(CURL_DISABLE_DOH) option(CURL_DISABLE_FILE "disables FILE" OFF) mark_as_advanced(CURL_DISABLE_FILE) +cmake_dependent_option(CURL_DISABLE_FORM_API "disables form api" OFF + "NOT CURL_DISABLE_MIME" ON) +mark_as_advanced(CURL_DISABLE_FORM_API) option(CURL_DISABLE_FTP "disables FTP" OFF) mark_as_advanced(CURL_DISABLE_FTP) option(CURL_DISABLE_GETOPTIONS "disables curl_easy_options API for existing options to curl_easy_setopt" OFF) diff --git a/configure.ac b/configure.ac index b2508b052d..a2d78d63d1 100644 --- a/configure.ac +++ b/configure.ac @@ -4126,6 +4126,32 @@ AS_HELP_STRING([--disable-mime],[Disable mime API support]), AC_MSG_RESULT(yes) ) +dnl ************************************************************ +dnl disable form API support +dnl +AC_MSG_CHECKING([whether to support the form API]) +AC_ARG_ENABLE(form-api, +AS_HELP_STRING([--enable-form-api],[Enable form API support]) +AS_HELP_STRING([--disable-form-api],[Disable form API support]), +[ case "$enableval" in + no) AC_MSG_RESULT(no) + AC_DEFINE(CURL_DISABLE_FORM_API, 1, [disable form API]) + ;; + *) AC_MSG_RESULT(yes) + test "$enable_mime" = no && + AC_MSG_ERROR(MIME support needs to be enabled in order to enable form API support) + ;; + esac ], +[ + if test "$enable_mime" = no; then + enable_form_api=no + AC_MSG_RESULT(no) + AC_DEFINE(CURL_DISABLE_FORM_API, 1, [disable form API]) + else + AC_MSG_RESULT(yes) + fi ] +) + dnl ************************************************************ dnl disable date parsing dnl diff --git a/docs/CURL-DISABLE.md b/docs/CURL-DISABLE.md index 1548df6bc9..e3098e8623 100644 --- a/docs/CURL-DISABLE.md +++ b/docs/CURL-DISABLE.md @@ -24,6 +24,10 @@ Disable DNS-over-HTTPS Disable the FILE protocol +## `CURL_DISABLE_FORM_API` + +Disable the form API + ## `CURL_DISABLE_FTP` Disable the FTP (and FTPS) protocol diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 1374e42b00..26cc5bcd4a 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -50,6 +50,9 @@ /* disables FILE */ #cmakedefine CURL_DISABLE_FILE 1 +/* disables form api */ +#cmakedefine CURL_DISABLE_FORM_API 1 + /* disables FTP */ #cmakedefine CURL_DISABLE_FTP 1 diff --git a/lib/formdata.c b/lib/formdata.c index 2bdb9f26ec..8984b63223 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -27,7 +27,7 @@ #include #include "formdata.h" -#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME) +#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_FORM_API) #if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME) #include @@ -941,7 +941,7 @@ int curl_formget(struct curl_httppost *form, void *arg, void curl_formfree(struct curl_httppost *form) { (void)form; - /* does nothing HTTP is disabled */ + /* Nothing to do. */ } #endif /* if disabled */ diff --git a/lib/formdata.h b/lib/formdata.h index caabb6324c..af466249fd 100644 --- a/lib/formdata.h +++ b/lib/formdata.h @@ -26,7 +26,7 @@ #include "curl_setup.h" -#ifndef CURL_DISABLE_MIME +#ifndef CURL_DISABLE_FORM_API /* used by FormAdd for temporary storage */ struct FormInfo { @@ -53,10 +53,7 @@ CURLcode Curl_getformdata(struct Curl_easy *data, curl_mimepart *, struct curl_httppost *post, curl_read_callback fread_func); -#else -/* disabled */ -#define Curl_getformdata(a,b,c,d) CURLE_NOT_BUILT_IN -#endif +#endif /* CURL_DISABLE_FORM_API */ #endif /* HEADER_CURL_FORMDATA_H */ diff --git a/lib/http.c b/lib/http.c index e611d27895..f6633528bc 100644 --- a/lib/http.c +++ b/lib/http.c @@ -2372,6 +2372,7 @@ CURLcode Curl_http_body(struct Curl_easy *data, struct connectdata *conn, case HTTPREQ_POST_MIME: http->sendit = &data->set.mimepost; break; +#ifndef CURL_DISABLE_FORM_API case HTTPREQ_POST_FORM: /* Convert the form structure into a mime structure. */ Curl_mime_cleanpart(&http->form); @@ -2381,6 +2382,7 @@ CURLcode Curl_http_body(struct Curl_easy *data, struct connectdata *conn, return result; http->sendit = &http->form; break; +#endif default: http->sendit = NULL; } diff --git a/lib/setopt.c b/lib/setopt.c index b05162a556..f22b175bf3 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -666,7 +666,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) data->set.method = HTTPREQ_GET; break; -#ifndef CURL_DISABLE_MIME +#ifndef CURL_DISABLE_FORM_API case CURLOPT_HTTPPOST: /* * Set to make us do HTTP POST diff --git a/tests/data/test1308 b/tests/data/test1308 index 7ec1b98840..bc799883fa 100644 --- a/tests/data/test1308 +++ b/tests/data/test1308 @@ -4,20 +4,21 @@ unittest curl_formadd curl_formget +FORM # # Client-side - -none - unittest http -Mime +form-api + +none + formpost unit tests diff --git a/tests/data/test516 b/tests/data/test516 index a47b051071..0878cceb93 100644 --- a/tests/data/test516 +++ b/tests/data/test516 @@ -3,6 +3,7 @@ HTTP HTTP POST +FORM @@ -22,7 +23,7 @@ OK # Client-side -Mime +form-api http diff --git a/tests/data/test554 b/tests/data/test554 index cee6164276..b446498950 100644 --- a/tests/data/test554 +++ b/tests/data/test554 @@ -3,6 +3,7 @@ HTTP HTTP POST +FORM @@ -39,7 +40,7 @@ hello # Client-side -Mime +form-api http diff --git a/tests/data/test587 b/tests/data/test587 index 6af7d9936d..ff11184a36 100644 --- a/tests/data/test587 +++ b/tests/data/test587 @@ -3,6 +3,7 @@ HTTP HTTP POST +FORM flaky @@ -17,7 +18,7 @@ flaky # Client-side -Mime +form-api http diff --git a/tests/data/test650 b/tests/data/test650 index c1dcd86438..e034e1cef9 100644 --- a/tests/data/test650 +++ b/tests/data/test650 @@ -24,7 +24,7 @@ hello # Client-side -Mime +form-api http diff --git a/tests/data/test651 b/tests/data/test651 index b58c224cb9..b076682ff5 100644 --- a/tests/data/test651 +++ b/tests/data/test651 @@ -24,7 +24,7 @@ hello # Client-side -Mime +form-api http diff --git a/tests/data/test672 b/tests/data/test672 index d7f1cccb0d..aab52381aa 100644 --- a/tests/data/test672 +++ b/tests/data/test672 @@ -33,7 +33,7 @@ hello # Client-side -Mime +form-api http diff --git a/tests/data/test673 b/tests/data/test673 index 0fd3f37320..ee86cccfaf 100644 --- a/tests/data/test673 +++ b/tests/data/test673 @@ -33,7 +33,7 @@ hello # Client-side -Mime +form-api http diff --git a/tests/runtests.pl b/tests/runtests.pl index bb3d00ef25..c24c3598be 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -783,6 +783,7 @@ sub checksystemfeatures { $feature{"DoH"} = 1; $feature{"HTTP-auth"} = 1; $feature{"Mime"} = 1; + $feature{"form-api"} = 1; $feature{"netrc"} = 1; $feature{"parsedate"} = 1; $feature{"proxy"} = 1; diff --git a/tests/server/disabled.c b/tests/server/disabled.c index 7ce2903881..635191a3eb 100644 --- a/tests/server/disabled.c +++ b/tests/server/disabled.c @@ -78,6 +78,9 @@ static const char *disabled[]={ #endif #ifndef USE_XATTR "xattr", +#endif +#ifdef CURL_DISABLE_FORM_API + "form-api", #endif NULL };