]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: Add test for CURLOPT_HTTP200ALIASES
authorVladimir Panteleev <git@cy.md>
Mon, 20 Dec 2021 17:55:33 +0000 (17:55 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 21 Dec 2021 07:45:06 +0000 (08:45 +0100)
tests/data/Makefile.inc
tests/data/test3025 [new file with mode: 0644]
tests/libtest/Makefile.inc
tests/libtest/lib3025.c [new file with mode: 0644]

index 2e317173cf4d39dfaf5724dbae543ab506ca29fe..75f6397ea35e598112625f6c0eba6e4e59218f39 100644 (file)
@@ -236,4 +236,4 @@ test2200 test2201 test2202 test2203 test2204 test2205 \
 test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
 test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \
 test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \
-test3024
+test3024 test3025
diff --git a/tests/data/test3025 b/tests/data/test3025
new file mode 100644 (file)
index 0000000..eaff47c
--- /dev/null
@@ -0,0 +1,47 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+ICY 200 OK
+Content-Length: 7
+
+MooMoo
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+<features>
+!hyper
+</features>
+<name>
+CURLOPT_HTTP200ALIASES
+</name>
+<tool>
+lib%TESTNUMBER
+</tool>
+<command>
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<errorcode>
+0
+</errorcode>
+</verify>
+</testcase>
index cbd16f5a431696128153d912777d28ca2bb6cfec..8721d550c1e06944ff98b4eeabaf97a664f3386b 100644 (file)
@@ -62,7 +62,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect                \
          lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 lib1912 lib1913 \
          lib1915 lib1916 lib1917 lib1918 lib1933 lib1934 lib1935 lib1936 \
  lib1937 lib1938 lib1939 \
- lib3010
+ lib3010 lib3025
 
 chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \
  ../../lib/curl_ctype.c  ../../lib/dynbuf.c ../../lib/strdup.c
@@ -727,3 +727,7 @@ lib1939_CPPFLAGS = $(AM_CPPFLAGS)
 lib3010_SOURCES = lib3010.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
 lib3010_LDADD = $(TESTUTIL_LIBS)
 lib3010_CPPFLAGS = $(AM_CPPFLAGS)
+
+lib3025_SOURCES = lib3025.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
+lib3025_LDADD = $(TESTUTIL_LIBS)
+lib3025_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/tests/libtest/lib3025.c b/tests/libtest/lib3025.c
new file mode 100644 (file)
index 0000000..57f89da
--- /dev/null
@@ -0,0 +1,59 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "memdebug.h"
+
+int test(char *URL)
+{
+  CURLcode res;
+  CURL *curl;
+  struct curl_slist *icy = NULL;
+
+  if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+    fprintf(stderr, "curl_global_init() failed\n");
+    return TEST_ERR_MAJOR_BAD;
+  }
+
+  curl = curl_easy_init();
+  if(!curl) {
+    fprintf(stderr, "curl_easy_init() failed\n");
+    curl_global_cleanup();
+    return TEST_ERR_MAJOR_BAD;
+  }
+
+  icy = curl_slist_append(icy, "ICY 200 OK");
+  test_setopt(curl, CURLOPT_HTTP200ALIASES, icy);
+  test_setopt(curl, CURLOPT_VERBOSE, 1L);
+  test_setopt(curl, CURLOPT_HEADER, 1L);
+  test_setopt(curl, CURLOPT_URL, URL);
+
+  res = curl_easy_perform(curl);
+
+test_cleanup:
+
+  curl_easy_cleanup(curl);
+  curl_slist_free_all(icy);
+  curl_global_cleanup();
+
+  return (int)res;
+}