]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
configure, cmake, lib: more form api deprecation
authorPatrick Monnerat <patrick@monnerat.net>
Tue, 15 Nov 2022 16:50:22 +0000 (17:50 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 31 Jul 2023 06:31:38 +0000 (08:31 +0200)
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

18 files changed:
CMakeLists.txt
configure.ac
docs/CURL-DISABLE.md
lib/curl_config.h.cmake
lib/formdata.c
lib/formdata.h
lib/http.c
lib/setopt.c
tests/data/test1308
tests/data/test516
tests/data/test554
tests/data/test587
tests/data/test650
tests/data/test651
tests/data/test672
tests/data/test673
tests/runtests.pl
tests/server/disabled.c

index 0327bfb3f7af453c383d5ebe939fba0e72ae7908..07e51849f5ea2f59a733b36a603167112daf3335 100644 (file)
@@ -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)
index b2508b052d8bb09f09dd87cc74bc4caabb40a887..a2d78d63d1069757e6a444533e1d4da4c6c26bf7 100644 (file)
@@ -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
index 1548df6bc97f7485b87018cf86dfe9e2967da3f7..e3098e8623fc9d46212314544d86cfdb6c7a7761 100644 (file)
@@ -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
index 1374e42b00973a3b7a1b440f45954d49bb8dceff..26cc5bcd4a5d649dc6579d5a279b9972b7e7688b 100644 (file)
@@ -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
 
index 2bdb9f26ecb7f49b264528e80e2bdee03465d45d..8984b63223cc0e64fafa3a59bfc7714d2da80eb9 100644 (file)
@@ -27,7 +27,7 @@
 #include <curl/curl.h>
 
 #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 <libgen.h>
@@ -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 */
index caabb6324c1583bd375a04cad1babfff9170cc51..af466249fdb62d4015872c13351de4d41ff66635 100644 (file)
@@ -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 */
index e611d2789552887f47da89d1fdec5f2eb3dbb15f..f6633528bc634c5546de70c7c49b75d7405f4594 100644 (file)
@@ -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;
   }
index b05162a556a10f64b3b00e21262f0e52a3d8f082..f22b175bf37ae758d11df291b8f6fa0ebc94d8ab 100644 (file)
@@ -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
index 7ec1b98840c268b06c0e1077f9bbcae931daf078..bc799883fa271a2ca64ad53f2a792ae93f2b7ba0 100644 (file)
@@ -4,20 +4,21 @@
 unittest
 curl_formadd
 curl_formget
+FORM
 </keywords>
 </info>
 
 #
 # Client-side
 <client>
-<server>
-none
-</server>
 <features>
 unittest
 http
-Mime
+form-api
 </features>
+<server>
+none
+</server>
  <name>
 formpost unit tests
  </name>
index a47b051071c3e7bd32b5c30006bcde0cc0e06296..0878cceb93bbf7ba9669e4e4746fa01c6480e6f2 100644 (file)
@@ -3,6 +3,7 @@
 <keywords>
 HTTP
 HTTP POST
+FORM
 </keywords>
 </info>
 
@@ -22,7 +23,7 @@ OK
 # Client-side
 <client>
 <features>
-Mime
+form-api
 </features>
 <server>
 http
index cee6164276e9872fd6dfc9c778a4674af63ef354..b446498950e852e719845870ca16eb4c474e9297 100644 (file)
@@ -3,6 +3,7 @@
 <keywords>
 HTTP
 HTTP POST
+FORM
 </keywords>
 </info>
 
@@ -39,7 +40,7 @@ hello
 # Client-side
 <client>
 <features>
-Mime
+form-api
 </features>
 <server>
 http
index 6af7d9936dcaaae9f5126f29fb89000d00dfd627..ff11184a36526f836a9440a58341a5c5aade9a1e 100644 (file)
@@ -3,6 +3,7 @@
 <keywords>
 HTTP
 HTTP POST
+FORM
 flaky
 </keywords>
 </info>
@@ -17,7 +18,7 @@ flaky
 # Client-side
 <client>
 <features>
-Mime
+form-api
 </features>
 <server>
 http
index c1dcd86438f166d9690ca12a254033d6ae412649..e034e1cef934b945add1bd01500a67a25addfb9b 100644 (file)
@@ -24,7 +24,7 @@ hello
 # Client-side
 <client>
 <features>
-Mime
+form-api
 </features>
 <server>
 http
index b58c224cb99a6cfbfe6ed4a98d604f42b96de9c5..b076682ff51575b4ec9cf5aef9a9d03fe5057001 100644 (file)
@@ -24,7 +24,7 @@ hello
 # Client-side
 <client>
 <features>
-Mime
+form-api
 </features>
 <server>
 http
index d7f1cccb0d6f7093f18f56c4b657f57ed5d70233..aab52381aa5c3344e2042fc3867a22c260248d4c 100644 (file)
@@ -33,7 +33,7 @@ hello
 # Client-side
 <client>
 <features>
-Mime
+form-api
 </features>
 <server>
 http
index 0fd3f37320261e233dc7848da867eac46bb436ad..ee86cccfaf9ba6120630d018ddea54e58000ac4d 100644 (file)
@@ -33,7 +33,7 @@ hello
 # Client-side
 <client>
 <features>
-Mime
+form-api
 </features>
 <server>
 http
index bb3d00ef25ca75450d454a098082afbd57dc6acd..c24c3598bec6c84ed5b0c83a86e8c0720be9118c 100755 (executable)
@@ -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;
index 7ce2903881c07c13ac49b75ec9cbcf1c2374f2ca..635191a3eb6ae48f69f8d21fc66036459ab5128d 100644 (file)
@@ -78,6 +78,9 @@ static const char *disabled[]={
 #endif
 #ifndef USE_XATTR
   "xattr",
+#endif
+#ifdef CURL_DISABLE_FORM_API
+  "form-api",
 #endif
   NULL
 };