From 6be0394059011a0b3a4770ddae22706232c38212 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 16 Mar 2022 09:20:48 +0100 Subject: [PATCH] make it build fine with HTTP-disabled --- include/curl/header.h | 3 ++- lib/headers.c | 29 +++++++++++++++++++++++++++++ lib/headers.h | 7 +++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/curl/header.h b/include/curl/header.h index cc7fbccbc84cd9..7e0d5322153030 100644 --- a/include/curl/header.h +++ b/include/curl/header.h @@ -46,7 +46,8 @@ typedef enum { CURLHE_MISSING, /* no such header exists */ CURLHE_NOHEADERS, /* no headers at all exist (yet) */ CURLHE_OUT_OF_MEMORY, /* out of memory while processing */ - CURLHE_BAD_ARGUMENT, + CURLHE_BAD_ARGUMENT, /* a function argument was not okay */ + CURLHE_NOT_BUILT_IN /* if API was disabled in the build */ } CURLHcode; CURL_EXTERN CURLHcode curl_easy_header(CURL *easy, diff --git a/lib/headers.c b/lib/headers.c index 6f185e284fbf27..f2cbcdb84fddb3 100644 --- a/lib/headers.c +++ b/lib/headers.c @@ -33,6 +33,8 @@ #include "curl_memory.h" #include "memdebug.h" +#ifndef CURL_DISABLE_HTTP + /* Generate the curl_header struct for the user. This function MUST assign all struct fields in the output struct. */ static void copy_header_external(struct Curl_easy *data, @@ -255,3 +257,30 @@ CURLcode Curl_headers_cleanup(struct Curl_easy *data) Curl_headers_init(data); return CURLE_OK; } + +#else /* HTTP-disabled builds below */ + +CURLHcode curl_easy_header(CURL *easy, + const char *name, + size_t index, + unsigned int type, + struct curl_header **hout) +{ + (void)easy; + (void)name; + (void)index; + (void)type; + (void)hout; + return CURLHE_NOT_BUILT_IN; +} + +struct curl_header *curl_easy_nextheader(CURL *easy, + unsigned int type, + struct curl_header *prev) +{ + (void)easy; + (void)type; + (void)prev; + return NULL; +} +#endif diff --git a/lib/headers.h b/lib/headers.h index c26a81f65f0a84..6bf59cdfc4f677 100644 --- a/lib/headers.h +++ b/lib/headers.h @@ -23,6 +23,8 @@ ***************************************************************************/ #include "curl_setup.h" +#ifndef CURL_DISABLE_HTTP + struct Curl_header_store { struct Curl_llist_element node; char *name; @@ -46,4 +48,9 @@ CURLcode Curl_headers_init(struct Curl_easy *data); */ CURLcode Curl_headers_cleanup(struct Curl_easy *data); +#else +#define Curl_headers_push(x,y,z) CURLE_NOT_BUILT_IN +#define Curl_headers_cleanup(x) Curl_nop_stmt +#endif + #endif /* HEADER_CURL_HEADER_H */