]> granicus.if.org Git - curl/commitdiff
Curl_checkheaders: make it available for IMAP and SMTP too
authorDaniel Stenberg <daniel@haxx.se>
Fri, 8 Sep 2017 13:13:42 +0000 (15:13 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 10 Sep 2017 22:26:17 +0000 (00:26 +0200)
... not only HTTP uses this now.

Closes #1875

lib/http.c
lib/http.h
lib/mime.c
lib/transfer.c
lib/transfer.h

index f4a1faac3c366981b4f0011b46a528e208b26532..e7f6872d576f031899581ecf2255477b7038a55a 100644 (file)
@@ -172,27 +172,6 @@ CURLcode Curl_http_setup_conn(struct connectdata *conn)
   return CURLE_OK;
 }
 
-/*
- * checkheaders() checks the linked list of custom HTTP headers for a
- * particular header (prefix).
- *
- * Returns a pointer to the first matching header or NULL if none matched.
- */
-char *Curl_checkheaders(const struct connectdata *conn,
-                        const char *thisheader)
-{
-  struct curl_slist *head;
-  size_t thislen = strlen(thisheader);
-  struct Curl_easy *data = conn->data;
-
-  for(head = data->set.headers;head; head=head->next) {
-    if(strncasecompare(head->data, thisheader, thislen))
-      return head->data;
-  }
-
-  return NULL;
-}
-
 /*
  * checkProxyHeaders() checks the linked list of custom proxy headers
  * if proxy headers are not available, then it will lookup into http header
index 3e446813f5c2e7e38bd6e871f8bdd0596582893e..d2781bc0f083016a61989bb633af307d457e6584 100644 (file)
@@ -40,8 +40,6 @@ bool Curl_compareheader(const char *headerline,  /* line to check */
                         const char *header,   /* header keyword _with_ colon */
                         const char *content); /* content string to find */
 
-char *Curl_checkheaders(const struct connectdata *conn,
-                        const char *thisheader);
 char *Curl_copy_header_value(const char *header);
 
 char *Curl_checkProxyheaders(const struct connectdata *conn,
index 514f6b2ae301f6a9bce7847347afb20d4d8ec587..74b653649d74e3506732e64d037d368c7c5160f1 100644 (file)
@@ -1820,7 +1820,7 @@ CURLcode curl_mime_headers(curl_mimepart *part,
 void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
 {
   (void) part;
-  (void) data;
+  (void) easy;
 }
 
 void Curl_mime_cleanpart(curl_mimepart *part)
index 24a21aa46021538d94366b84902dbded01e7861c..b36de280363878d183a01d4fe0a7c83c69c82d65 100644 (file)
 #include "non-ascii.h"
 #include "http2.h"
 #include "mime.h"
+#include "strcase.h"
 
 /* The last 3 #include files should be in this order */
 #include "curl_printf.h"
 #include "curl_memory.h"
 #include "memdebug.h"
 
+#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
+    !defined(CURL_DISABLE_IMAP)
+/*
+ * checkheaders() checks the linked list of custom headers for a
+ * particular header (prefix).
+ *
+ * Returns a pointer to the first matching header or NULL if none matched.
+ */
+char *Curl_checkheaders(const struct connectdata *conn,
+                        const char *thisheader)
+{
+  struct curl_slist *head;
+  size_t thislen = strlen(thisheader);
+  struct Curl_easy *data = conn->data;
+
+  for(head = data->set.headers;head; head=head->next) {
+    if(strncasecompare(head->data, thisheader, thislen))
+      return head->data;
+  }
+
+  return NULL;
+}
+#endif
+
 /*
  * This function will call the read callback to fill our buffer with data
  * to upload.
index 51896726050f030064de38218972ea8dc1e89d79..72526a8348afdfbd38e67a51d5d42eaf08789472 100644 (file)
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -22,6 +22,9 @@
  *
  ***************************************************************************/
 
+char *Curl_checkheaders(const struct connectdata *conn,
+                        const char *thisheader);
+
 void Curl_init_CONNECT(struct Curl_easy *data);
 
 CURLcode Curl_pretransfer(struct Curl_easy *data);