From 2c1dbc1af0a774ae5dce08150131a01e862c13b5 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Mon, 20 Dec 2021 17:55:33 +0000 Subject: tests: Add test for CURLOPT_HTTP200ALIASES --- tests/data/Makefile.inc | 2 +- tests/data/test3025 | 47 ++++++++++++++++++++++++++++++++++++ tests/libtest/Makefile.inc | 6 ++++- tests/libtest/lib3025.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 tests/data/test3025 create mode 100644 tests/libtest/lib3025.c diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index 2e317173c..75f6397ea 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -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 index 000000000..eaff47ce7 --- /dev/null +++ b/tests/data/test3025 @@ -0,0 +1,47 @@ + + + +HTTP +HTTP GET + + + +# +# Server-side + + +ICY 200 OK +Content-Length: 7 + +MooMoo + + + +# +# Client-side + + +http + + +!hyper + + +CURLOPT_HTTP200ALIASES + + +lib%TESTNUMBER + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER + + + +# +# Verify data after the test has been "shot" + + +0 + + + diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index cbd16f5a4..8721d550c 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -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 index 000000000..57f89da24 --- /dev/null +++ b/tests/libtest/lib3025.c @@ -0,0 +1,59 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2020, Daniel Stenberg, , 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; +} -- cgit v1.2.1