Update libcurl

This commit is contained in:
Glenn Smith 2022-09-03 01:31:41 -04:00
parent 20eb0a911a
commit 01a719ee58
No known key found for this signature in database
GPG key ID: 9B71EC283F0B7A14
3439 changed files with 529259 additions and 41492 deletions

View file

@ -0,0 +1,2 @@
disable TYPEDEFSTRUCT
disable BANNEDFUNC

View file

@ -0,0 +1,85 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2022, 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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
set(TARGET_LABEL_PREFIX "Test ")
function(setup_test TEST_NAME) # ARGN are the files in the test
add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
add_dependencies(testdeps ${TEST_NAME})
string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
include_directories(
${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h"
${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h"
${CURL_SOURCE_DIR}/tests/libtest # To be able to build generated tests
)
if(USE_ARES)
include_directories(${CARES_INCLUDE_DIR})
endif()
target_link_libraries(${TEST_NAME} libcurl ${CURL_LIBS})
set_target_properties(${TEST_NAME}
PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME})
set_target_properties(${TEST_NAME}
PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}")
endfunction()
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
foreach(TEST_NAME ${noinst_PROGRAMS})
if(DEFINED ${TEST_NAME}_SOURCES)
setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES})
else()
setup_test(${TEST_NAME} ${nodist_${TEST_NAME}_SOURCES})
endif()
endforeach()
# Allows for hostname override to make tests machine independent.
# TODO this cmake build assumes a shared build, detect static linking here!
if(NOT WIN32)
add_library(hostname MODULE EXCLUDE_FROM_ALL sethostname.c sethostname.h)
add_dependencies(testdeps hostname)
# Output to .libs for compatibility with autotools, the test data expects a
# library at (tests)/libtest/.libs/libhostname.so
set_target_properties(hostname PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.libs)
if(HIDES_CURL_PRIVATE_SYMBOLS)
set_property(TARGET hostname APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS")
set_property(TARGET hostname APPEND PROPERTY COMPILE_FLAGS ${CURL_CFLAG_SYMBOLS_HIDE})
endif()
endif()
add_custom_command(
OUTPUT lib1521.c
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl < ${CURL_SOURCE_DIR}/include/curl/curl.h > lib1521.c
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl"
"${CURL_SOURCE_DIR}/include/curl/curl.h"
VERBATIM)
set_property(TARGET chkdecimalpoint
APPEND PROPERTY COMPILE_DEFINITIONS "CURLX_NO_MEMORY_CALLBACKS;CURL_STATICLIB")

View file

@ -0,0 +1,140 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2022, 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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
AUTOMAKE_OPTIONS = foreign nostdinc
# Specify our include paths here, and do it relative to $(top_srcdir) and
# $(top_builddir), to ensure that these paths which belong to the library
# being currently built and tested are searched before the library which
# might possibly already be installed in the system.
#
# $(top_srcdir)/include is for libcurl's external include files
# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "borrowed" files
AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib
EXTRA_DIST = test307.pl test610.pl test613.pl test1013.pl test1022.pl \
Makefile.inc notexists.pl CMakeLists.txt mk-lib1521.pl .checksrc
CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@
CFLAGS += @CURL_CFLAG_EXTRAS@
CLEANFILES = lib1521.c
# Prevent LIBS from being used for all link targets
LIBS = $(BLANK_AT_MAKETIME)
if USE_EXPLICIT_LIB_DEPS
SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@
TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@
else
SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_LIBS@ @NSS_LIBS@
TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ @NSS_LIBS@
endif
# Dependencies (may need to be overridden)
LDADD = $(SUPPORTFILES_LIBS)
# Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES,
# noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS)
include Makefile.inc
# Preloading of libhostname allows host name overriding,
# this is used to make some tests machine independent.
if BUILD_LIBHOSTNAME
noinst_LTLIBRARIES = libhostname.la
else
noinst_LTLIBRARIES =
endif
if USE_CPPFLAG_CURL_STATICLIB
AM_CPPFLAGS += -DCURL_STATICLIB
endif
AM_LDFLAGS =
AM_CFLAGS =
libhostname_la_CPPFLAGS_EXTRA =
libhostname_la_LDFLAGS_EXTRA = -module -avoid-version -rpath /nowhere
libhostname_la_CFLAGS_EXTRA =
libstubgss_la_LDFLAGS_EXTRA =
if CURL_LT_SHLIB_USE_NO_UNDEFINED
libhostname_la_LDFLAGS_EXTRA += -no-undefined
libstubgss_la_LDFLAGS_EXTRA += -no-undefined
endif
if CURL_LT_SHLIB_USE_MIMPURE_TEXT
libhostname_la_LDFLAGS_EXTRA += -mimpure-text
endif
if DOING_CURL_SYMBOL_HIDING
libhostname_la_CPPFLAGS_EXTRA += -DCURL_HIDDEN_SYMBOLS
libhostname_la_CFLAGS_EXTRA += $(CFLAG_CURL_SYMBOL_HIDING)
endif
libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) $(libhostname_la_CPPFLAGS_EXTRA)
libhostname_la_LDFLAGS = $(AM_LDFLAGS) $(libhostname_la_LDFLAGS_EXTRA)
libhostname_la_CFLAGS = $(AM_CFLAGS) $(libhostname_la_CFLAGS_EXTRA)
libhostname_la_SOURCES = sethostname.c sethostname.h
libhostname_la_LIBADD =
libhostname_la_DEPENDENCIES =
# Build a stub gssapi implementation for testing
if BUILD_STUB_GSS
noinst_LTLIBRARIES += libstubgss.la
libstubgss_la_CPPFLAGS = $(AM_CPPFLAGS)
libstubgss_la_LDFLAGS = $(AM_LDFLAGS) $(libstubgss_la_LDFLAGS_EXTRA) -avoid-version -rpath /nowhere
libstubgss_la_CFLAGS = $(AM_CFLAGS) -g
libstubgss_la_SOURCES = stub_gssapi.c stub_gssapi.h
libstubgss_la_LIBADD =
libstubgss_la_DEPENDENCIES =
endif
lib1521.c: $(top_srcdir)/tests/libtest/mk-lib1521.pl $(top_srcdir)/include/curl/curl.h
@PERL@ $(top_srcdir)/tests/libtest/mk-lib1521.pl < $(top_srcdir)/include/curl/curl.h > lib1521.c
CHECKSRC = $(CS_$(V))
CS_0 = @echo " RUN " $@;
CS_1 =
CS_ = $(CS_0)
checksrc:
$(CHECKSRC)@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) $(srcdir)/*.[ch]
if CURLDEBUG
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,761 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2022, 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.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# files used only in some libcurl test programs
TESTUTIL = testutil.c testutil.h
# files used only in some libcurl test programs
TSTTRACE = testtrace.c testtrace.h
# files used only in some libcurl test programs
WARNLESS = ../../lib/warnless.c ../../lib/warnless.h
# files used only in some libcurl test programs
MULTIBYTE = ../../lib/curl_multibyte.c ../../lib/curl_multibyte.h
# these files are used in every single test program below
SUPPORTFILES = ../../lib/timediff.c ../../lib/timediff.h first.c test.h
# These are all libcurl test programs
noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
chkdecimalpoint libprereq \
lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 lib509 \
lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519 \
lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib529 lib530 lib532 \
lib533 lib537 lib539 lib540 lib541 lib542 lib543 lib544 lib545 \
lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 lib557 lib558 \
lib559 lib560 lib562 lib564 lib565 lib566 lib567 lib568 lib569 lib570 \
lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \
lib583 lib584 lib585 lib586 lib587 lib589 lib590 lib591 lib597 lib598 \
lib599 \
lib643 lib645 lib650 lib651 lib652 lib653 lib654 lib655 lib658 \
lib659 lib661 lib666 lib667 lib668 \
lib670 lib671 lib672 lib673 lib674 lib676 lib677 lib678 \
lib1156 \
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \
lib1518 lib1520 lib1521 lib1522 lib1523 \
lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \
lib1534 lib1535 lib1536 lib1537 lib1538 lib1539 \
lib1540 lib1542 lib1543 \
lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \
lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 lib1568 lib1569 \
lib1591 lib1592 lib1593 lib1594 lib1596 lib1597 \
lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 lib1912 lib1913 \
lib1915 lib1916 lib1917 lib1918 lib1919 \
lib1933 lib1934 lib1935 lib1936 lib1937 lib1938 lib1939 lib1940 \
lib1945 lib1946 \
lib3010 lib3025 lib3026
chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \
../../lib/curl_ctype.c ../../lib/dynbuf.c ../../lib/strdup.c
chkdecimalpoint_LDADD =
chkdecimalpoint_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB \
-DCURLX_NO_MEMORY_CALLBACKS -DBUILDING_LIBCURL
chkhostname_SOURCES = chkhostname.c ../../lib/curl_gethostname.c
chkhostname_LDADD = @CURL_NETWORK_LIBS@
chkhostname_DEPENDENCIES =
chkhostname_CPPFLAGS = $(AM_CPPFLAGS)
libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
libntlmconnect_LDADD = $(TESTUTIL_LIBS)
libntlmconnect_CPPFLAGS = $(AM_CPPFLAGS)
libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES)
libauthretry_CPPFLAGS = $(AM_CPPFLAGS)
libprereq_SOURCES = libprereq.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
libprereq_LDADD = $(TESTUTIL_LIBS)
libprereq_CPPFLAGS = $(AM_CPPFLAGS)
lib500_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) $(MULTIBYTE)
lib500_LDADD = $(TESTUTIL_LIBS)
lib500_CPPFLAGS = $(AM_CPPFLAGS)
lib501_SOURCES = lib501.c $(SUPPORTFILES)
lib501_CPPFLAGS = $(AM_CPPFLAGS)
lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib502_LDADD = $(TESTUTIL_LIBS)
lib502_CPPFLAGS = $(AM_CPPFLAGS)
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib503_LDADD = $(TESTUTIL_LIBS)
lib503_CPPFLAGS = $(AM_CPPFLAGS)
lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib504_LDADD = $(TESTUTIL_LIBS)
lib504_CPPFLAGS = $(AM_CPPFLAGS)
lib505_SOURCES = lib505.c $(SUPPORTFILES) $(MULTIBYTE)
lib505_CPPFLAGS = $(AM_CPPFLAGS)
lib506_SOURCES = lib506.c $(SUPPORTFILES)
lib506_CPPFLAGS = $(AM_CPPFLAGS)
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib507_LDADD = $(TESTUTIL_LIBS)
lib507_CPPFLAGS = $(AM_CPPFLAGS)
lib508_SOURCES = lib508.c $(SUPPORTFILES)
lib508_CPPFLAGS = $(AM_CPPFLAGS)
lib509_SOURCES = lib509.c $(SUPPORTFILES)
lib509_CPPFLAGS = $(AM_CPPFLAGS)
lib510_SOURCES = lib510.c $(SUPPORTFILES)
lib510_CPPFLAGS = $(AM_CPPFLAGS)
lib511_SOURCES = lib511.c $(SUPPORTFILES)
lib511_CPPFLAGS = $(AM_CPPFLAGS)
lib512_SOURCES = lib512.c $(SUPPORTFILES)
lib512_CPPFLAGS = $(AM_CPPFLAGS)
lib513_SOURCES = lib513.c $(SUPPORTFILES)
lib513_CPPFLAGS = $(AM_CPPFLAGS)
lib514_SOURCES = lib514.c $(SUPPORTFILES)
lib514_CPPFLAGS = $(AM_CPPFLAGS)
lib515_SOURCES = lib515.c $(SUPPORTFILES)
lib515_CPPFLAGS = $(AM_CPPFLAGS)
lib516_SOURCES = lib516.c $(SUPPORTFILES)
lib516_CPPFLAGS = $(AM_CPPFLAGS)
lib517_SOURCES = lib517.c $(SUPPORTFILES)
lib517_CPPFLAGS = $(AM_CPPFLAGS)
lib518_SOURCES = lib518.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE)
lib518_CPPFLAGS = $(AM_CPPFLAGS)
lib519_SOURCES = lib519.c $(SUPPORTFILES)
lib519_CPPFLAGS = $(AM_CPPFLAGS)
lib520_SOURCES = lib520.c $(SUPPORTFILES)
lib520_CPPFLAGS = $(AM_CPPFLAGS)
lib521_SOURCES = lib521.c $(SUPPORTFILES)
lib521_CPPFLAGS = $(AM_CPPFLAGS)
lib523_SOURCES = lib523.c $(SUPPORTFILES)
lib523_CPPFLAGS = $(AM_CPPFLAGS)
lib524_SOURCES = lib524.c $(SUPPORTFILES)
lib524_CPPFLAGS = $(AM_CPPFLAGS)
lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
lib525_LDADD = $(TESTUTIL_LIBS)
lib525_CPPFLAGS = $(AM_CPPFLAGS)
lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib526_LDADD = $(TESTUTIL_LIBS)
lib526_CPPFLAGS = $(AM_CPPFLAGS) -DLIB526
lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib527_LDADD = $(TESTUTIL_LIBS)
lib527_CPPFLAGS = $(AM_CPPFLAGS) -DLIB527
lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
lib529_LDADD = $(TESTUTIL_LIBS)
lib529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB529
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib530_LDADD = $(TESTUTIL_LIBS)
lib530_CPPFLAGS = $(AM_CPPFLAGS)
lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib532_LDADD = $(TESTUTIL_LIBS)
lib532_CPPFLAGS = $(AM_CPPFLAGS) -DLIB532
lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib533_LDADD = $(TESTUTIL_LIBS)
lib533_CPPFLAGS = $(AM_CPPFLAGS)
lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE)
lib537_CPPFLAGS = $(AM_CPPFLAGS)
lib539_SOURCES = lib539.c $(SUPPORTFILES)
lib539_CPPFLAGS = $(AM_CPPFLAGS)
lib540_SOURCES = lib540.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib540_LDADD = $(TESTUTIL_LIBS)
lib540_CPPFLAGS = $(AM_CPPFLAGS)
lib541_SOURCES = lib541.c $(SUPPORTFILES) $(MULTIBYTE)
lib541_CPPFLAGS = $(AM_CPPFLAGS)
lib542_SOURCES = lib542.c $(SUPPORTFILES)
lib542_CPPFLAGS = $(AM_CPPFLAGS)
lib543_SOURCES = lib543.c $(SUPPORTFILES)
lib543_CPPFLAGS = $(AM_CPPFLAGS)
lib544_SOURCES = lib544.c $(SUPPORTFILES)
lib544_CPPFLAGS = $(AM_CPPFLAGS)
lib545_SOURCES = lib544.c $(SUPPORTFILES)
lib545_CPPFLAGS = $(AM_CPPFLAGS) -DLIB545
lib547_SOURCES = lib547.c $(SUPPORTFILES)
lib547_CPPFLAGS = $(AM_CPPFLAGS)
lib548_SOURCES = lib547.c $(SUPPORTFILES)
lib548_CPPFLAGS = $(AM_CPPFLAGS) -DLIB548
lib549_SOURCES = lib549.c $(SUPPORTFILES)
lib549_CPPFLAGS = $(AM_CPPFLAGS)
lib552_SOURCES = lib552.c $(SUPPORTFILES) $(WARNLESS)
lib552_CPPFLAGS = $(AM_CPPFLAGS)
lib553_SOURCES = lib553.c $(SUPPORTFILES)
lib553_CPPFLAGS = $(AM_CPPFLAGS)
lib554_SOURCES = lib554.c $(SUPPORTFILES)
lib554_CPPFLAGS = $(AM_CPPFLAGS)
lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib555_LDADD = $(TESTUTIL_LIBS)
lib555_CPPFLAGS = $(AM_CPPFLAGS)
lib556_SOURCES = lib556.c $(SUPPORTFILES) $(WARNLESS)
lib556_CPPFLAGS = $(AM_CPPFLAGS)
lib557_SOURCES = lib557.c $(SUPPORTFILES)
lib557_CPPFLAGS = $(AM_CPPFLAGS)
lib558_SOURCES = lib558.c $(SUPPORTFILES)
lib558_CPPFLAGS = $(AM_CPPFLAGS)
lib559_SOURCES = lib559.c $(SUPPORTFILES)
lib559_CPPFLAGS = $(AM_CPPFLAGS)
lib560_SOURCES = lib560.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib560_LDADD = $(TESTUTIL_LIBS)
lib560_CPPFLAGS = $(AM_CPPFLAGS)
lib562_SOURCES = lib562.c $(SUPPORTFILES)
lib562_CPPFLAGS = $(AM_CPPFLAGS)
lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib564_LDADD = $(TESTUTIL_LIBS)
lib564_CPPFLAGS = $(AM_CPPFLAGS)
lib565_SOURCES = lib510.c $(SUPPORTFILES)
lib565_CPPFLAGS = $(AM_CPPFLAGS) -DLIB565
lib566_SOURCES = lib566.c $(SUPPORTFILES) $(MULTIBYTE)
lib566_CPPFLAGS = $(AM_CPPFLAGS)
lib567_SOURCES = lib567.c $(SUPPORTFILES)
lib567_CPPFLAGS = $(AM_CPPFLAGS)
lib568_SOURCES = lib568.c $(SUPPORTFILES) $(MULTIBYTE)
lib568_CPPFLAGS = $(AM_CPPFLAGS)
lib569_SOURCES = lib569.c $(SUPPORTFILES) $(MULTIBYTE)
lib569_CPPFLAGS = $(AM_CPPFLAGS)
lib570_SOURCES = lib570.c $(SUPPORTFILES)
lib570_CPPFLAGS = $(AM_CPPFLAGS)
lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE)
lib571_CPPFLAGS = $(AM_CPPFLAGS)
lib572_SOURCES = lib572.c $(SUPPORTFILES) $(MULTIBYTE)
lib572_CPPFLAGS = $(AM_CPPFLAGS)
lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(TSTTRACE)
lib573_LDADD = $(TESTUTIL_LIBS)
lib573_CPPFLAGS = $(AM_CPPFLAGS)
lib574_SOURCES = lib574.c $(SUPPORTFILES)
lib574_CPPFLAGS = $(AM_CPPFLAGS)
lib575_SOURCES = lib575.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib575_LDADD = $(TESTUTIL_LIBS)
lib575_CPPFLAGS = $(AM_CPPFLAGS)
lib576_SOURCES = lib576.c $(SUPPORTFILES)
lib576_CPPFLAGS = $(AM_CPPFLAGS)
lib578_SOURCES = lib578.c $(SUPPORTFILES) $(MULTIBYTE)
lib578_CPPFLAGS = $(AM_CPPFLAGS)
lib579_SOURCES = lib579.c $(SUPPORTFILES) $(MULTIBYTE)
lib579_CPPFLAGS = $(AM_CPPFLAGS)
lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
lib582_LDADD = $(TESTUTIL_LIBS)
lib582_CPPFLAGS = $(AM_CPPFLAGS)
lib583_SOURCES = lib583.c $(SUPPORTFILES)
lib583_CPPFLAGS = $(AM_CPPFLAGS)
lib584_SOURCES = lib589.c $(SUPPORTFILES)
lib584_CPPFLAGS = $(AM_CPPFLAGS) -DLIB584
lib585_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) $(MULTIBYTE)
lib585_LDADD = $(TESTUTIL_LIBS)
lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585
lib586_SOURCES = lib586.c $(SUPPORTFILES)
lib586_CPPFLAGS = $(AM_CPPFLAGS)
lib587_SOURCES = lib554.c $(SUPPORTFILES)
lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587
lib589_SOURCES = lib589.c $(SUPPORTFILES)
lib589_CPPFLAGS = $(AM_CPPFLAGS)
lib590_SOURCES = lib590.c $(SUPPORTFILES)
lib590_CPPFLAGS = $(AM_CPPFLAGS)
lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
lib591_LDADD = $(TESTUTIL_LIBS)
lib591_CPPFLAGS = $(AM_CPPFLAGS)
lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib597_LDADD = $(TESTUTIL_LIBS)
lib597_CPPFLAGS = $(AM_CPPFLAGS)
lib598_SOURCES = lib598.c $(SUPPORTFILES)
lib598_CPPFLAGS = $(AM_CPPFLAGS)
lib599_SOURCES = lib599.c $(SUPPORTFILES) $(MULTIBYTE)
lib599_CPPFLAGS = $(AM_CPPFLAGS)
lib643_SOURCES = lib643.c $(SUPPORTFILES)
lib643_CPPFLAGS = $(AM_CPPFLAGS)
lib645_SOURCES = lib643.c $(SUPPORTFILES)
lib645_CPPFLAGS = $(AM_CPPFLAGS) -DLIB645
lib650_SOURCES = lib650.c $(SUPPORTFILES)
lib650_CPPFLAGS = $(AM_CPPFLAGS)
lib651_SOURCES = lib651.c $(SUPPORTFILES)
lib651_CPPFLAGS = $(AM_CPPFLAGS)
lib652_SOURCES = lib652.c $(SUPPORTFILES)
lib652_CPPFLAGS = $(AM_CPPFLAGS)
lib653_SOURCES = lib653.c $(SUPPORTFILES)
lib653_CPPFLAGS = $(AM_CPPFLAGS)
lib654_SOURCES = lib654.c $(SUPPORTFILES)
lib654_CPPFLAGS = $(AM_CPPFLAGS)
lib655_SOURCES = lib655.c $(SUPPORTFILES)
lib655_CPPFLAGS = $(AM_CPPFLAGS)
lib658_SOURCES = lib658.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib658_LDADD = $(TESTUTIL_LIBS)
lib658_CPPFLAGS = $(AM_CPPFLAGS)
lib659_SOURCES = lib659.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib659_LDADD = $(TESTUTIL_LIBS)
lib659_CPPFLAGS = $(AM_CPPFLAGS)
lib661_SOURCES = lib661.c $(SUPPORTFILES)
lib661_CPPFLAGS = $(AM_CPPFLAGS)
lib666_SOURCES = lib666.c $(SUPPORTFILES)
lib666_CPPFLAGS = $(AM_CPPFLAGS)
lib667_SOURCES = lib667.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib667_LDADD = $(TESTUTIL_LIBS)
lib667_CPPFLAGS = $(AM_CPPFLAGS)
lib668_SOURCES = lib668.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib668_LDADD = $(TESTUTIL_LIBS)
lib668_CPPFLAGS = $(AM_CPPFLAGS)
lib670_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib670_LDADD = $(TESTUTIL_LIBS)
lib670_CPPFLAGS = $(AM_CPPFLAGS) -DLIB670
lib671_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib671_LDADD = $(TESTUTIL_LIBS)
lib671_CPPFLAGS = $(AM_CPPFLAGS) -DLIB671
lib672_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib672_LDADD = $(TESTUTIL_LIBS)
lib672_CPPFLAGS = $(AM_CPPFLAGS) -DLIB672
lib673_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib673_LDADD = $(TESTUTIL_LIBS)
lib673_CPPFLAGS = $(AM_CPPFLAGS) -DLIB673
lib674_SOURCES = lib674.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib674_LDADD = $(TESTUTIL_LIBS)
lib674_CPPFLAGS = $(AM_CPPFLAGS)
lib676_SOURCES = lib676.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib676_LDADD = $(TESTUTIL_LIBS)
lib676_CPPFLAGS = $(AM_CPPFLAGS)
lib677_SOURCES = lib677.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
lib677_LDADD = $(TESTUTIL_LIBS)
lib677_CPPFLAGS = $(AM_CPPFLAGS)
lib678_SOURCES = lib678.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
lib678_LDADD = $(TESTUTIL_LIBS)
lib678_CPPFLAGS = $(AM_CPPFLAGS)
lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL)
lib1500_LDADD = $(TESTUTIL_LIBS)
lib1500_CPPFLAGS = $(AM_CPPFLAGS)
lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1501_LDADD = $(TESTUTIL_LIBS)
lib1501_CPPFLAGS = $(AM_CPPFLAGS)
lib1502_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1502_LDADD = $(TESTUTIL_LIBS)
lib1502_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1502
lib1503_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1503_LDADD = $(TESTUTIL_LIBS)
lib1503_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1503
lib1504_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1504_LDADD = $(TESTUTIL_LIBS)
lib1504_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1504
lib1505_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1505_LDADD = $(TESTUTIL_LIBS)
lib1505_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1505
lib1506_SOURCES = lib1506.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1506_LDADD = $(TESTUTIL_LIBS)
lib1506_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1506
lib1156_SOURCES = lib1156.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1156_LDADD = $(TESTUTIL_LIBS)
lib1156_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1156
lib1507_SOURCES = lib1507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1507_LDADD = $(TESTUTIL_LIBS)
lib1507_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1507
lib1508_SOURCES = lib1508.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1508_LDADD = $(TESTUTIL_LIBS)
lib1508_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1508
lib1509_SOURCES = lib1509.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1509_LDADD = $(TESTUTIL_LIBS)
lib1509_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1509
lib1510_SOURCES = lib1510.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1510_LDADD = $(TESTUTIL_LIBS)
lib1510_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1510
lib1511_SOURCES = lib1511.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1511_LDADD = $(TESTUTIL_LIBS)
lib1511_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1511
lib1512_SOURCES = lib1512.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1512_LDADD = $(TESTUTIL_LIBS)
lib1512_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1512
lib1513_SOURCES = lib1513.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1513_LDADD = $(TESTUTIL_LIBS)
lib1513_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1513
lib1514_SOURCES = lib1514.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1514_LDADD = $(TESTUTIL_LIBS)
lib1514_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1514
lib1515_SOURCES = lib1515.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1515_LDADD = $(TESTUTIL_LIBS)
lib1515_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1515
lib1517_SOURCES = lib1517.c $(SUPPORTFILES)
lib1517_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1517
lib1518_SOURCES = lib1518.c $(SUPPORTFILES)
lib1518_CPPFLAGS = $(AM_CPPFLAGS)
lib1520_SOURCES = lib1520.c $(SUPPORTFILES)
lib1520_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1520
nodist_lib1521_SOURCES = lib1521.c $(SUPPORTFILES)
lib1521_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)
lib1522_SOURCES = lib1522.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE)
lib1522_LDADD = $(TESTUTIL_LIBS)
lib1522_CPPFLAGS = $(AM_CPPFLAGS)
lib1523_SOURCES = lib1523.c $(SUPPORTFILES)
lib1523_CPPFLAGS = $(AM_CPPFLAGS)
lib1525_SOURCES = lib1525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1525_LDADD = $(TESTUTIL_LIBS)
lib1525_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1525
lib1526_SOURCES = lib1526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1526_LDADD = $(TESTUTIL_LIBS)
lib1526_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1526
lib1527_SOURCES = lib1527.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1527_LDADD = $(TESTUTIL_LIBS)
lib1527_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1527
lib1528_SOURCES = lib1528.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1528_LDADD = $(TESTUTIL_LIBS)
lib1528_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1528
lib1529_SOURCES = lib1529.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1529_LDADD = $(TESTUTIL_LIBS)
lib1529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1529
lib1530_SOURCES = lib1530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1530_LDADD = $(TESTUTIL_LIBS)
lib1530_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1530
lib1531_SOURCES = lib1531.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1531_LDADD = $(TESTUTIL_LIBS)
lib1531_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1531
lib1532_SOURCES = lib1532.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1532_LDADD = $(TESTUTIL_LIBS)
lib1532_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1532
lib1533_SOURCES = lib1533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1533_LDADD = $(TESTUTIL_LIBS)
lib1533_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1533
lib1534_SOURCES = lib1534.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1534_LDADD = $(TESTUTIL_LIBS)
lib1534_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1534
lib1535_SOURCES = lib1535.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1535_LDADD = $(TESTUTIL_LIBS)
lib1535_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1535
lib1536_SOURCES = lib1536.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1536_LDADD = $(TESTUTIL_LIBS)
lib1536_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1536
lib1537_SOURCES = lib1537.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1537_LDADD = $(TESTUTIL_LIBS)
lib1537_CPPFLAGS = $(AM_CPPFLAGS)
lib1538_SOURCES = lib1538.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1538_LDADD = $(TESTUTIL_LIBS)
lib1538_CPPFLAGS = $(AM_CPPFLAGS)
lib1539_SOURCES = lib1514.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1539_LDADD = $(TESTUTIL_LIBS)
lib1539_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1539
lib1540_SOURCES = lib1540.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1540_LDADD = $(TESTUTIL_LIBS)
lib1540_CPPFLAGS = $(AM_CPPFLAGS)
lib1542_SOURCES = lib1542.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) $(WARNLESS)
lib1542_LDADD = $(TESTUTIL_LIBS)
lib1542_CPPFLAGS = $(AM_CPPFLAGS)
lib1543_SOURCES = lib1518.c $(SUPPORTFILES)
lib1543_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1543
lib1550_SOURCES = lib1550.c $(SUPPORTFILES)
lib1550_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1517
lib1551_SOURCES = lib1551.c $(SUPPORTFILES)
lib1551_CPPFLAGS = $(AM_CPPFLAGS)
lib1552_SOURCES = lib1552.c $(SUPPORTFILES) $(TESTUTIL)
lib1552_LDADD = $(TESTUTIL_LIBS)
lib1552_CPPFLAGS = $(AM_CPPFLAGS)
lib1553_SOURCES = lib1553.c $(SUPPORTFILES) $(TESTUTIL)
lib1553_LDADD = $(TESTUTIL_LIBS)
lib1553_CPPFLAGS = $(AM_CPPFLAGS)
lib1554_SOURCES = lib1554.c $(SUPPORTFILES)
lib1554_CPPFLAGS = $(AM_CPPFLAGS)
lib1555_SOURCES = lib1555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1555_LDADD = $(TESTUTIL_LIBS)
lib1555_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1555
lib1556_SOURCES = lib1556.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1556_LDADD = $(TESTUTIL_LIBS)
lib1556_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1556
lib1557_SOURCES = lib1557.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1557_LDADD = $(TESTUTIL_LIBS)
lib1557_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1557
lib1558_SOURCES = lib1558.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1558_LDADD = $(TESTUTIL_LIBS)
lib1559_SOURCES = lib1559.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1559_LDADD = $(TESTUTIL_LIBS)
lib1560_SOURCES = lib1560.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1560_LDADD = $(TESTUTIL_LIBS)
lib1564_SOURCES = lib1564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1564_LDADD = $(TESTUTIL_LIBS)
lib1564_CPPFLAGS = $(AM_CPPFLAGS)
lib1565_SOURCES = lib1565.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1565_LDADD = $(TESTUTIL_LIBS)
lib1565_CPPFLAGS = $(AM_CPPFLAGS)
lib1567_SOURCES = lib1567.c $(SUPPORTFILES)
lib1567_CPPFLAGS = $(AM_CPPFLAGS)
lib1568_SOURCES = lib1568.c $(SUPPORTFILES)
lib1568_CPPFLAGS = $(AM_CPPFLAGS)
lib1569_SOURCES = lib1569.c $(SUPPORTFILES)
lib1569_CPPFLAGS = $(AM_CPPFLAGS)
lib1591_SOURCES = lib1591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1591_LDADD = $(TESTUTIL_LIBS)
lib1591_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1591
lib1592_SOURCES = lib1592.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1592_LDADD = $(TESTUTIL_LIBS)
lib1592_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1592
lib1593_SOURCES = lib1593.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1593_LDADD = $(TESTUTIL_LIBS)
lib1594_SOURCES = lib1594.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1594_LDADD = $(TESTUTIL_LIBS)
lib1596_SOURCES = lib1594.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1596_LDADD = $(TESTUTIL_LIBS)
lib1596_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1596
lib1597_SOURCES = lib1597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1597_LDADD = $(TESTUTIL_LIBS)
lib1905_SOURCES = lib1905.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1905_LDADD = $(TESTUTIL_LIBS)
lib1905_CPPFLAGS = $(AM_CPPFLAGS)
lib1906_SOURCES = lib1906.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1906_LDADD = $(TESTUTIL_LIBS)
lib1906_CPPFLAGS = $(AM_CPPFLAGS)
lib1907_SOURCES = lib1907.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1907_LDADD = $(TESTUTIL_LIBS)
lib1907_CPPFLAGS = $(AM_CPPFLAGS)
lib1908_SOURCES = lib1908.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1908_LDADD = $(TESTUTIL_LIBS)
lib1908_CPPFLAGS = $(AM_CPPFLAGS)
lib1910_SOURCES = lib1910.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1910_LDADD = $(TESTUTIL_LIBS)
lib1910_CPPFLAGS = $(AM_CPPFLAGS)
lib1911_SOURCES = lib1911.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1911_LDADD = $(TESTUTIL_LIBS)
lib1911_CPPFLAGS = $(AM_CPPFLAGS)
lib1912_SOURCES = lib1912.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1912_LDADD = $(TESTUTIL_LIBS)
lib1912_CPPFLAGS = $(AM_CPPFLAGS)
lib1913_SOURCES = lib1913.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1913_LDADD = $(TESTUTIL_LIBS)
lib1913_CPPFLAGS = $(AM_CPPFLAGS)
lib1915_SOURCES = lib1915.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1915_LDADD = $(TESTUTIL_LIBS)
lib1915_CPPFLAGS = $(AM_CPPFLAGS)
lib1916_SOURCES = lib1916.c $(SUPPORTFILES) $(WARNLESS)
lib1916_CPPFLAGS = $(AM_CPPFLAGS)
lib1917_SOURCES = lib1916.c $(SUPPORTFILES) $(WARNLESS)
lib1917_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1917
lib1918_SOURCES = lib1918.c $(SUPPORTFILES) $(WARNLESS)
lib1918_CPPFLAGS = $(AM_CPPFLAGS)
lib1919_SOURCES = lib1919.c $(SUPPORTFILES) $(WARNLESS)
lib1919_CPPFLAGS = $(AM_CPPFLAGS)
lib1933_SOURCES = lib1933.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1933_LDADD = $(TESTUTIL_LIBS)
lib1933_CPPFLAGS = $(AM_CPPFLAGS)
lib1934_SOURCES = lib1934.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1934_LDADD = $(TESTUTIL_LIBS)
lib1934_CPPFLAGS = $(AM_CPPFLAGS)
lib1935_SOURCES = lib1935.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1935_LDADD = $(TESTUTIL_LIBS)
lib1935_CPPFLAGS = $(AM_CPPFLAGS)
lib1936_SOURCES = lib1936.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1936_LDADD = $(TESTUTIL_LIBS)
lib1936_CPPFLAGS = $(AM_CPPFLAGS)
lib1937_SOURCES = lib1937.c $(SUPPORTFILES)
lib1937_LDADD = $(TESTUTIL_LIBS)
lib1937_CPPFLAGS = $(AM_CPPFLAGS)
lib1938_SOURCES = lib1938.c $(SUPPORTFILES)
lib1938_LDADD = $(TESTUTIL_LIBS)
lib1938_CPPFLAGS = $(AM_CPPFLAGS)
lib1939_SOURCES = lib1939.c $(SUPPORTFILES)
lib1939_LDADD = $(TESTUTIL_LIBS)
lib1939_CPPFLAGS = $(AM_CPPFLAGS)
lib1940_SOURCES = lib1940.c $(SUPPORTFILES)
lib1940_LDADD = $(TESTUTIL_LIBS)
lib1940_CPPFLAGS = $(AM_CPPFLAGS)
lib1945_SOURCES = lib1945.c $(SUPPORTFILES)
lib1945_LDADD = $(TESTUTIL_LIBS)
lib1945_CPPFLAGS = $(AM_CPPFLAGS)
lib1946_SOURCES = lib1940.c $(SUPPORTFILES)
lib1946_LDADD = $(TESTUTIL_LIBS)
lib1946_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1946
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)
lib3026_SOURCES = lib3026.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib3026_LDADD = $(TESTUTIL_LIBS)
lib3026_CPPFLAGS = $(AM_CPPFLAGS)

View file

@ -0,0 +1,43 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "curl_printf.h"
#include <string.h>
#include <locale.h>
#define TOTAL_STR_LEN 4
int main(void)
{
char zero[TOTAL_STR_LEN] = {'\0'};
int chars;
setlocale(LC_NUMERIC, "");
chars = msnprintf(zero, TOTAL_STR_LEN, "%.1f", 0.0);
if((chars == (TOTAL_STR_LEN - 1)) && (strcmp(zero, "0.0") == 0))
return 0;
else
return 1;
}

View file

@ -0,0 +1,49 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "curl_setup.h"
#include "curl_gethostname.h"
#define HOSTNAME_MAX 1024
int main(int argc, char *argv[])
{
char buff[HOSTNAME_MAX];
if(argc != 2) {
printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]);
return 1;
}
if(Curl_gethostname(buff, HOSTNAME_MAX)) {
printf("Curl_gethostname() failed\n");
return 1;
}
/* compare the name returned by Curl_gethostname() with the expected one */
if(strncmp(buff, argv[1], HOSTNAME_MAX)) {
printf("got unexpected host name back, LD_PRELOAD failed\n");
return 1;
}
return 0;
}

View file

@ -0,0 +1,194 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_LOCALE_H
# include <locale.h> /* for setlocale() */
#endif
#ifdef HAVE_IO_H
# include <io.h> /* for setmode() */
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h> /* for setmode() */
#endif
#ifdef USE_NSS
#include <nspr.h>
#endif
#ifdef CURLDEBUG
# define MEMDEBUG_NODEFINES
# include "memdebug.h"
#endif
#include "timediff.h"
int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv)
{
if(nfds < 0) {
SET_SOCKERRNO(EINVAL);
return -1;
}
#ifdef USE_WINSOCK
/*
* Winsock select() requires that at least one of the three fd_set
* pointers is not NULL and points to a non-empty fdset. IOW Winsock
* select() can not be used to sleep without a single fd_set.
*/
if(!nfds) {
Sleep((DWORD)curlx_tvtoms(tv));
return 0;
}
#endif
return select(nfds, rd, wr, exc, tv);
}
void wait_ms(int ms)
{
#ifdef USE_WINSOCK
Sleep(ms);
#else
struct timeval t;
curlx_mstotv(&t, ms);
select_wrapper(0, NULL, NULL, NULL, &t);
#endif
}
char *libtest_arg2 = NULL;
char *libtest_arg3 = NULL;
int test_argc;
char **test_argv;
struct timeval tv_test_start; /* for test timing */
#ifdef UNITTESTS
int unitfail; /* for unittests */
#endif
#ifdef CURLDEBUG
static void memory_tracking_init(void)
{
char *env;
/* if CURL_MEMDEBUG is set, this starts memory tracking message logging */
env = curl_getenv("CURL_MEMDEBUG");
if(env) {
/* use the value as file name */
char fname[CURL_MT_LOGFNAME_BUFSIZE];
if(strlen(env) >= CURL_MT_LOGFNAME_BUFSIZE)
env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0';
strcpy(fname, env);
curl_free(env);
curl_dbg_memdebug(fname);
/* this weird stuff here is to make curl_free() get called before
curl_dbg_memdebug() as otherwise memory tracking will log a free()
without an alloc! */
}
/* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
env = curl_getenv("CURL_MEMLIMIT");
if(env) {
char *endptr;
long num = strtol(env, &endptr, 10);
if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
curl_dbg_memlimit(num);
curl_free(env);
}
}
#else
# define memory_tracking_init() Curl_nop_stmt
#endif
/* returns a hexdump in a static memory area */
char *hexdump(const unsigned char *buffer, size_t len)
{
static char dump[200 * 3 + 1];
char *p = dump;
size_t i;
if(len > 200)
return NULL;
for(i = 0; i<len; i++, p += 3)
msnprintf(p, 4, "%02x ", buffer[i]);
return dump;
}
int main(int argc, char **argv)
{
char *URL;
int result;
#ifdef O_BINARY
# ifdef __HIGHC__
_setmode(stdout, O_BINARY);
# else
setmode(fileno(stdout), O_BINARY);
# endif
#endif
memory_tracking_init();
/*
* Setup proper locale from environment. This is needed to enable locale-
* specific behavior by the C library in order to test for undesired side
* effects that could cause in libcurl.
*/
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
if(argc< 2) {
fprintf(stderr, "Pass URL as argument please\n");
return 1;
}
test_argc = argc;
test_argv = argv;
if(argc>2)
libtest_arg2 = argv[2];
if(argc>3)
libtest_arg3 = argv[3];
URL = argv[1]; /* provide this to the rest */
fprintf(stderr, "URL: %s\n", URL);
result = test(URL);
#ifdef USE_NSS
if(PR_Initialized())
/* prevent valgrind from reporting possibly lost memory (fd cache, ...) */
PR_Cleanup();
#endif
#ifdef WIN32
/* flush buffers of all streams regardless of mode */
_flushall();
#endif
return result;
}

View file

@ -0,0 +1,173 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
/*
Check range/resume returned error codes and data presence.
The input parameters are:
- CURLOPT_RANGE/CURLOPT_RESUME_FROM
- CURLOPT_FAILONERROR
- Returned http code (2xx/416)
- Content-Range header present in reply.
*/
#include "memdebug.h"
#define F_RESUME (1 << 0) /* resume/range. */
#define F_HTTP416 (1 << 1) /* Server returns http code 416. */
#define F_FAIL (1 << 2) /* Fail on error. */
#define F_CONTENTRANGE (1 << 3) /* Server sends content-range hdr. */
#define F_IGNOREBODY (1 << 4) /* Body should be ignored. */
struct testparams {
unsigned int flags; /* ORed flags as above. */
CURLcode result; /* Code that should be returned by curl_easy_perform(). */
};
static const struct testparams params[] = {
{ 0, CURLE_OK },
{ F_CONTENTRANGE, CURLE_OK },
{ F_FAIL, CURLE_OK },
{ F_FAIL | F_CONTENTRANGE, CURLE_OK },
{ F_HTTP416, CURLE_OK },
{ F_HTTP416 | F_CONTENTRANGE, CURLE_OK },
{ F_HTTP416 | F_FAIL | F_IGNOREBODY,
CURLE_HTTP_RETURNED_ERROR },
{ F_HTTP416 | F_FAIL | F_CONTENTRANGE | F_IGNOREBODY,
CURLE_HTTP_RETURNED_ERROR },
{ F_RESUME | F_IGNOREBODY,
CURLE_RANGE_ERROR },
{ F_RESUME | F_CONTENTRANGE, CURLE_OK },
{ F_RESUME | F_FAIL | F_IGNOREBODY,
CURLE_RANGE_ERROR },
{ F_RESUME | F_FAIL | F_CONTENTRANGE, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_IGNOREBODY, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_CONTENTRANGE | F_IGNOREBODY, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_FAIL | F_IGNOREBODY, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_FAIL | F_CONTENTRANGE | F_IGNOREBODY,
CURLE_HTTP_RETURNED_ERROR }
};
static int hasbody;
static size_t writedata(char *data, size_t size, size_t nmemb, void *userdata)
{
(void) data;
(void) userdata;
if(size && nmemb)
hasbody = 1;
return size * nmemb;
}
static int onetest(CURL *curl, const char *url, const struct testparams *p,
size_t num)
{
CURLcode res;
unsigned int replyselector;
char urlbuf[256];
replyselector = (p->flags & F_CONTENTRANGE)? 1: 0;
if(p->flags & F_HTTP416)
replyselector += 2;
msnprintf(urlbuf, sizeof(urlbuf), "%s%04u", url, replyselector);
test_setopt(curl, CURLOPT_URL, urlbuf);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_RESUME_FROM, (p->flags & F_RESUME)? 3: 0);
test_setopt(curl, CURLOPT_RANGE, !(p->flags & F_RESUME)?
"3-1000000": (char *) NULL);
test_setopt(curl, CURLOPT_FAILONERROR, (p->flags & F_FAIL)? 1: 0);
hasbody = 0;
res = curl_easy_perform(curl);
if(res != p->result) {
printf("%d: bad error code (%d): resume=%s, fail=%s, http416=%s, "
"content-range=%s, expected=%d\n", num, res,
(p->flags & F_RESUME)? "yes": "no",
(p->flags & F_FAIL)? "yes": "no",
(p->flags & F_HTTP416)? "yes": "no",
(p->flags & F_CONTENTRANGE)? "yes": "no",
p->result);
return 1;
}
if(hasbody && (p->flags & F_IGNOREBODY)) {
printf("body should be ignored and is not: resume=%s, fail=%s, "
"http416=%s, content-range=%s\n",
(p->flags & F_RESUME)? "yes": "no",
(p->flags & F_FAIL)? "yes": "no",
(p->flags & F_HTTP416)? "yes": "no",
(p->flags & F_CONTENTRANGE)? "yes": "no");
return 1;
}
return 0;
test_cleanup:
return 1;
}
/* for debugging: */
/*#define SINGLETEST 9*/
int test(char *URL)
{
CURLcode res;
CURL *curl;
size_t i;
int status = 0;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_WRITEFUNCTION, writedata);
#ifdef SINGLETEST
if(SINGLETEST == i)
#endif
status |= onetest(curl, URL, params + i, i);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
printf("%d\n", status);
return status;
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,92 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *curls = NULL;
CURLM *multi = NULL;
int still_running;
int i = TEST_ERR_FAILURE;
int res = 0;
CURLMsg *msg;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running) {
int num;
res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
if(res != CURLM_OK) {
printf("curl_multi_wait() returned %d\n", res);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}

View file

@ -0,0 +1,113 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 30 * 1000
/* 500 milliseconds allowed. An extreme number but lets be really conservative
to allow old and slow machines to run this test too */
#define MAX_BLOCKED_TIME_MS 500
int test(char *URL)
{
CURL *handle = NULL;
CURLM *mhandle = NULL;
int res = 0;
int still_running = 0;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(handle);
easy_setopt(handle, CURLOPT_URL, URL);
easy_setopt(handle, CURLOPT_VERBOSE, 1L);
multi_init(mhandle);
multi_add_handle(mhandle, handle);
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
struct timeval before;
struct timeval after;
long e;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
fprintf(stderr, "ping\n");
before = tutil_tvnow();
multi_perform(mhandle, &still_running);
abort_on_test_timeout();
after = tutil_tvnow();
e = tutil_tvdiff(after, before);
fprintf(stderr, "pong = %ld\n", e);
if(e > MAX_BLOCKED_TIME_MS) {
res = 100;
break;
}
}
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(mhandle);
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,159 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* This source code is used for lib1502, lib1503, lib1504 and lib1505 with
* only #ifdefs controlling the cleanup sequence.
*
* Test case 1502 converted from bug report #3575448, identifying a memory
* leak in the CURLOPT_RESOLVE handling with the multi interface.
*/
#include "test.h"
#include <limits.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *easy = NULL;
CURL *dup;
CURLM *multi = NULL;
int still_running;
int res = 0;
char redirect[160];
/* DNS cache injection */
struct curl_slist *dns_cache_list;
res_global_init(CURL_GLOBAL_ALL);
if(res) {
return res;
}
msnprintf(redirect, sizeof(redirect), "google.com:%s:%s", libtest_arg2,
libtest_arg3);
start_test_timing();
dns_cache_list = curl_slist_append(NULL, redirect);
if(!dns_cache_list) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
easy_init(easy);
easy_setopt(easy, CURLOPT_URL, URL);
easy_setopt(easy, CURLOPT_HEADER, 1L);
easy_setopt(easy, CURLOPT_RESOLVE, dns_cache_list);
dup = curl_easy_duphandle(easy);
if(dup) {
curl_easy_cleanup(easy);
easy = dup;
}
else {
curl_slist_free_all(dns_cache_list);
curl_easy_cleanup(easy);
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
multi_init(multi);
multi_add_handle(multi, easy);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
test_cleanup:
#ifdef LIB1502
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(easy);
curl_global_cleanup();
#endif
#ifdef LIB1503
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(multi, easy);
curl_multi_cleanup(multi);
curl_easy_cleanup(easy);
curl_global_cleanup();
#endif
#ifdef LIB1504
/* undocumented cleanup sequence - type UB */
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_global_cleanup();
#endif
#ifdef LIB1505
/* proper cleanup sequence - type PB */
curl_multi_remove_handle(multi, easy);
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_global_cleanup();
#endif
curl_slist_free_all(dns_cache_list);
return res;
}

View file

@ -0,0 +1,139 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2022, Linus Nielsen Feltzing <linus@haxx.se>
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define NUM_HANDLES 4
int test(char *URL)
{
int res = 0;
CURL *curl[NUM_HANDLES] = {0};
int running;
CURLM *m = NULL;
int i;
char target_url[256];
char dnsentry[256];
struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
(void)URL;
/* Create fake DNS entries for serverX.example.com for all handles */
for(i = 0; i < NUM_HANDLES; i++) {
msnprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s",
i + 1, port, address);
printf("%s\n", dnsentry);
slist2 = curl_slist_append(slist, dnsentry);
if(!slist2) {
fprintf(stderr, "curl_slist_append() failed\n");
goto test_cleanup;
}
slist = slist2;
}
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(m);
multi_setopt(m, CURLMOPT_MAXCONNECTS, 3L);
/* get NUM_HANDLES easy handles */
for(i = 0; i < NUM_HANDLES; i++) {
/* get an easy handle */
easy_init(curl[i]);
/* specify target */
msnprintf(target_url, sizeof(target_url),
"http://server%d.example.com:%s/path/1506%04i",
i + 1, port, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl[i], CURLOPT_URL, target_url);
/* go verbose */
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl[i], CURLOPT_HEADER, 1L);
easy_setopt(curl[i], CURLOPT_RESOLVE, slist);
}
fprintf(stderr, "Start at URL 0\n");
for(i = 0; i < NUM_HANDLES; i++) {
/* add handle to multi */
multi_add_handle(m, curl[i]);
for(;;) {
struct timeval interval;
fd_set rd, wr, exc;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
wait_ms(1); /* to ensure different end times */
}
test_cleanup:
/* proper cleanup sequence - type PB */
for(i = 0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(m, curl[i]);
curl_easy_cleanup(curl[i]);
}
curl_slist_free_all(slist);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,152 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "timediff.h"
#include "warnless.h"
#include "memdebug.h"
/*
* This is the list of basic details you need to tweak to get things right.
*/
#define USERNAME "user@example.com"
#define PASSWORD "123qwerty"
#define RECIPIENT "<1507-recipient@example.com>"
#define MAILFROM "<1507-realuser@example.com>"
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
(void)ptr;
(void)size;
(void)nmemb;
(void)userp;
return CURL_READFUNC_ABORT;
}
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
CURLM *mcurl = NULL;
int still_running = 1;
struct timeval mp_start;
struct curl_slist *rcpt_list = NULL;
curl_global_init(CURL_GLOBAL_DEFAULT);
easy_init(curl);
multi_init(mcurl);
rcpt_list = curl_slist_append(rcpt_list, RECIPIENT);
/* more addresses can be added here
rcpt_list = curl_slist_append(rcpt_list, "<others@example.com>");
*/
curl_easy_setopt(curl, CURLOPT_URL, URL);
#if 0
curl_easy_setopt(curl, CURLOPT_USERNAME, USERNAME);
curl_easy_setopt(curl, CURLOPT_PASSWORD, PASSWORD);
#endif
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, MAILFROM);
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
multi_add_handle(mcurl, curl);
mp_start = tutil_tvnow();
/* we start some action by calling perform right away */
curl_multi_perform(mcurl, &still_running);
while(still_running) {
struct timeval timeout;
int rc; /* select() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -1;
long curl_timeo = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_timeout(mcurl, &curl_timeo);
if(curl_timeo >= 0) {
curlx_mstotv(&timeout, curl_timeo);
if(timeout.tv_sec > 1) {
timeout.tv_sec = 1;
timeout.tv_usec = 0;
}
}
/* get file descriptors from the transfers */
curl_multi_fdset(mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
function calls. On success, the value of maxfd is guaranteed to be
greater or equal than -1. We call select(maxfd + 1, ...), specially in
case of (maxfd == -1), we call select(0, ...), which is basically equal
to sleep. */
rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
if(tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n");
break;
}
switch(rc) {
case -1:
/* select error */
break;
case 0: /* timeout */
default: /* action */
curl_multi_perform(mcurl, &still_running);
break;
}
}
test_cleanup:
curl_slist_free_all(rcpt_list);
curl_multi_remove_handle(mcurl, curl);
curl_multi_cleanup(mcurl);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,51 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2022, Linus Nielsen Feltzing <linus@haxx.se>
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
int res = 0;
CURLM *m = NULL;
(void)URL;
global_init(CURL_GLOBAL_ALL);
multi_init(m);
test_cleanup:
/* proper cleanup sequence - type PB */
curl_multi_cleanup(m);
curl_global_cleanup();
printf("We are done\n");
return res;
}

View file

@ -0,0 +1,99 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream);
size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream);
static unsigned long realHeaderSize = 0;
int test(char *URL)
{
long headerSize;
CURLcode code;
CURL *curl = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
easy_setopt(curl, CURLOPT_WRITEFUNCTION, *WriteOutput);
easy_setopt(curl, CURLOPT_HEADERFUNCTION, *WriteHeader);
easy_setopt(curl, CURLOPT_HEADER, 1L);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
code = curl_easy_perform(curl);
if(CURLE_OK != code) {
fprintf(stderr, "%s:%d curl_easy_perform() failed, "
"with code %d (%s)\n",
__FILE__, __LINE__, (int)code, curl_easy_strerror(code));
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
code = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize);
if(CURLE_OK != code) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed, "
"with code %d (%s)\n",
__FILE__, __LINE__, (int)code, curl_easy_strerror(code));
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
printf("header length is ........: %ld\n", headerSize);
printf("header length should be..: %lu\n", realHeaderSize);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream)
{
fwrite(ptr, size, nmemb, stream);
return nmemb * size;
}
size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream)
{
(void)ptr;
(void)stream;
realHeaderSize += curlx_uztoul(size * nmemb);
return nmemb * size;
}

View file

@ -0,0 +1,101 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2022, Linus Nielsen Feltzing <linus@haxx.se>
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define NUM_URLS 4
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
int i;
char target_url[256];
char dnsentry[256];
struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
(void)URL;
/* Create fake DNS entries for serverX.example.com for all handles */
for(i = 0; i < NUM_URLS; i++) {
msnprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1,
port, address);
printf("%s\n", dnsentry);
slist2 = curl_slist_append(slist, dnsentry);
if(!slist2) {
fprintf(stderr, "curl_slist_append() failed\n");
goto test_cleanup;
}
slist = slist2;
}
start_test_timing();
global_init(CURL_GLOBAL_ALL);
/* get an easy handle */
easy_init(curl);
/* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl, CURLOPT_HEADER, 1L);
easy_setopt(curl, CURLOPT_RESOLVE, slist);
easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
/* get NUM_HANDLES easy handles */
for(i = 0; i < NUM_URLS; i++) {
/* specify target */
msnprintf(target_url, sizeof(target_url),
"http://server%d.example.com:%s/path/1510%04i",
i + 1, port, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl, CURLOPT_URL, target_url);
res = curl_easy_perform(curl);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PB */
curl_easy_cleanup(curl);
curl_slist_free_all(slist);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,77 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
long unmet;
CURL *curl = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_HEADER, 1L);
easy_setopt(curl, CURLOPT_TIMECONDITION, (long)CURL_TIMECOND_IFMODSINCE);
/* TIMEVALUE in the future */
easy_setopt(curl, CURLOPT_TIMEVALUE, 1566210680L);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
if(unmet != 1L) {
res = TEST_ERR_FAILURE; /* not correct */
goto test_cleanup;
}
/* TIMEVALUE in the past */
easy_setopt(curl, CURLOPT_TIMEVALUE, 1L);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
if(unmet) {
res = TEST_ERR_FAILURE; /* not correct */
goto test_cleanup;
}
res = TEST_ERR_SUCCESS; /* this is where we should be */
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,92 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2022, Linus Nielsen Feltzing <linus@haxx.se>
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* Use global DNS cache (while deprecated it should still work), populate it
* with CURLOPT_RESOLVE in the first request and then make sure a subsequent
* easy transfer finds and uses the populated stuff.
*/
#include "test.h"
#include "memdebug.h"
#define NUM_HANDLES 2
int test(char *URL)
{
int res = 0;
CURL *curl[NUM_HANDLES] = {NULL, NULL};
char *port = libtest_arg3;
char *address = libtest_arg2;
char dnsentry[256];
struct curl_slist *slist = NULL;
int i;
char target_url[256];
(void)URL; /* URL is setup in the code */
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
msnprintf(dnsentry, sizeof(dnsentry), "server.example.curl:%s:%s",
port, address);
printf("%s\n", dnsentry);
slist = curl_slist_append(slist, dnsentry);
/* get NUM_HANDLES easy handles */
for(i = 0; i < NUM_HANDLES; i++) {
/* get an easy handle */
easy_init(curl[i]);
/* specify target */
msnprintf(target_url, sizeof(target_url),
"http://server.example.curl:%s/path/1512%04i",
port, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl[i], CURLOPT_URL, target_url);
/* go verbose */
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl[i], CURLOPT_HEADER, 1L);
easy_setopt(curl[i], CURLOPT_DNS_USE_GLOBAL_CACHE, 1L);
}
/* make the first one populate the GLOBAL cache */
easy_setopt(curl[0], CURLOPT_RESOLVE, slist);
/* run NUM_HANDLES transfers */
for(i = 0; (i < NUM_HANDLES) && !res; i++)
res = curl_easy_perform(curl[i]);
test_cleanup:
curl_easy_cleanup(curl[0]);
curl_easy_cleanup(curl[1]);
curl_slist_free_all(slist);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,76 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* Test case converted from bug report #1318 by Petr Novak.
*
* Before the fix, this test program returned 52 (CURLE_GOT_NOTHING) instead
* of 42 (CURLE_ABORTED_BY_CALLBACK).
*/
#include "test.h"
#include "memdebug.h"
static int progressKiller(void *arg,
double dltotal,
double dlnow,
double ultotal,
double ulnow)
{
(void)arg;
(void)dltotal;
(void)dlnow;
(void)ultotal;
(void)ulnow;
printf("PROGRESSFUNCTION called\n");
return 1;
}
int test(char *URL)
{
CURL *curl;
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_TIMEOUT, (long)7);
easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressKiller);
easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
res = curl_easy_perform(curl);
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,86 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* Make sure libcurl does not send a `Content-Length: -1` header when HTTP POST
* size is unknown.
*/
#include "test.h"
#include "memdebug.h"
static char data[]="dummy";
struct WriteThis {
char *readptr;
size_t sizeleft;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct WriteThis *pooh = (struct WriteThis *)userp;
if(size*nmemb < 1)
return 0;
if(pooh->sizeleft) {
*ptr = pooh->readptr[0]; /* copy one single byte */
pooh->readptr++; /* advance pointer */
pooh->sizeleft--; /* less data left */
return 1; /* we return 1 byte at a time! */
}
return 0; /* no more data left to deliver */
}
int test(char *URL)
{
CURL *curl;
CURLcode result = CURLE_OK;
int res = 0;
struct WriteThis pooh = { data, sizeof(data)-1 };
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_POST, 1L);
/* Purposely omit to set CURLOPT_POSTFIELDSIZE */
easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
easy_setopt(curl, CURLOPT_READDATA, &pooh);
#ifdef LIB1539
/* speak HTTP 1.0 - no chunked! */
easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
#endif
result = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)result;
}

View file

@ -0,0 +1,156 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* Check for bugs #1303 and #1327: libcurl should never remove DNS entries
* created via CURLOPT_RESOLVE, neither after DNS_CACHE_TIMEOUT elapses
* (test1515) nor a dead connection is detected (test1616).
*/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define DNS_TIMEOUT 1
#if defined(WIN32) || defined(_WIN32)
#define sleep(sec) Sleep ((sec)*1000)
#endif
static int debug_callback(CURL *curl, curl_infotype info, char *msg,
size_t len, void *ptr)
{
(void)curl;
(void)ptr;
if(info == CURLINFO_TEXT)
fprintf(stderr, "debug: %.*s", (int) len, msg);
return 0;
}
static int do_one_request(CURLM *m, char *URL, char *resolve)
{
CURL *curls;
struct curl_slist *resolve_list = NULL;
int still_running;
int res = 0;
CURLMsg *msg;
int msgs_left;
resolve_list = curl_slist_append(resolve_list, resolve);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_RESOLVE, resolve_list);
easy_setopt(curls, CURLOPT_DEBUGFUNCTION, debug_callback);
easy_setopt(curls, CURLOPT_VERBOSE, 1);
easy_setopt(curls, CURLOPT_DNS_CACHE_TIMEOUT, DNS_TIMEOUT);
multi_add_handle(m, curls);
multi_perform(m, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread, fdwrite, fdexcep;
int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(m, &still_running);
abort_on_test_timeout();
}
do {
msg = curl_multi_info_read(m, &msgs_left);
if(msg && msg->msg == CURLMSG_DONE && msg->easy_handle == curls) {
res = msg->data.result;
break;
}
} while(msg);
test_cleanup:
curl_multi_remove_handle(m, curls);
curl_easy_cleanup(curls);
curl_slist_free_all(resolve_list);
return res;
}
int test(char *URL)
{
CURLM *multi = NULL;
int res = 0;
char *address = libtest_arg2;
char *port = libtest_arg3;
char *path = URL;
char dns_entry[256];
int i;
int count = 2;
msnprintf(dns_entry, sizeof(dns_entry), "testserver.example.com:%s:%s",
port, address);
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
for(i = 1; i <= count; i++) {
char target_url[256];
msnprintf(target_url, sizeof(target_url),
"http://testserver.example.com:%s/%s%04d", port, path, i);
/* second request must succeed like the first one */
res = do_one_request(multi, target_url, dns_entry);
if(res)
goto test_cleanup;
if(i < count)
sleep(DNS_TIMEOUT + 1);
}
test_cleanup:
curl_multi_cleanup(multi);
curl_global_cleanup();
return (int) res;
}

View file

@ -0,0 +1,113 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static char data[]="this is what we post to the silly web server\n";
struct WriteThis {
char *readptr;
size_t sizeleft;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct WriteThis *pooh = (struct WriteThis *)userp;
size_t tocopy = size * nmemb;
/* Wait one second before return POST data *
* so libcurl will wait before sending request body */
wait_ms(1000);
if(tocopy < 1 || !pooh->sizeleft)
return 0;
if(pooh->sizeleft < tocopy)
tocopy = pooh->sizeleft;
memcpy(ptr, pooh->readptr, tocopy);/* copy requested data */
pooh->readptr += tocopy; /* advance pointer */
pooh->sizeleft -= tocopy; /* less data left */
return tocopy;
}
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
struct WriteThis pooh;
pooh.readptr = data;
pooh.sizeleft = strlen(data);
if(curl_global_init(CURL_GLOBAL_ALL)) {
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;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* detect HTTP error codes >= 400 */
/* test_setopt(curl, CURLOPT_FAILONERROR, 1L); */
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,106 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test inspired by github issue 3340 */
static size_t writecb(char *buffer, size_t size, size_t nitems,
void *outstream)
{
(void)buffer;
(void)size;
(void)nitems;
(void)outstream;
return 0;
}
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
long curlResponseCode;
long curlRedirectCount;
char *effectiveUrl = NULL;
char *redirectUrl = NULL;
#ifdef LIB1543
CURLU *urlu = NULL;
#endif
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
#ifdef LIB1543
/* set CURLOPT_URLU */
{
CURLUcode rc = CURLUE_OK;
urlu = curl_url();
if(urlu)
rc = curl_url_set(urlu, CURLUPART_URL, URL, CURLU_ALLOW_SPACE);
if(!urlu || rc) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_CURLU, urlu);
}
test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
#else
test_setopt(curl, CURLOPT_URL, URL);
/* just to make it explicit and visible in this test: */
test_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
#endif
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &curlResponseCode);
curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &curlRedirectCount);
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effectiveUrl);
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirectUrl);
res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
printf("res %d\n"
"status %d\n"
"redirects %d\n"
"effectiveurl %s\n"
"redirecturl %s\n",
(int)res,
(int)curlResponseCode,
(int)curlRedirectCount,
effectiveUrl,
redirectUrl ? redirectUrl : "blank");
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
#ifdef LIB1543
curl_url_cleanup(urlu);
#endif
return res;
}

View file

@ -0,0 +1,115 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014 - 2022, Steve Holme, <steve_holme@hotmail.com>.
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/*
* This is the list of basic details you need to tweak to get things right.
*/
#define TO "<recipient@example.com>"
#define FROM "<sender@example.com>"
static const char *payload_text[] = {
"From: different\r\n",
"To: another\r\n",
"\r\n",
"\r\n",
".\r\n",
".\r\n",
"\r\n",
".\r\n",
"\r\n",
"body",
NULL
};
struct upload_status {
int lines_read;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct upload_status *upload_ctx = (struct upload_status *)userp;
const char *data;
if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
return 0;
}
data = payload_text[upload_ctx->lines_read];
if(data) {
size_t len = strlen(data);
memcpy(ptr, data, len);
upload_ctx->lines_read++;
return len;
}
return 0;
}
int test(char *URL)
{
CURLcode res;
CURL *curl;
struct curl_slist *rcpt_list = NULL;
struct upload_status upload_ctx = {0};
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;
}
rcpt_list = curl_slist_append(rcpt_list, TO);
/* more addresses can be added here
rcpt_list = curl_slist_append(rcpt_list, "<others@example.com>");
*/
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_READDATA, &upload_ctx);
test_setopt(curl, CURLOPT_MAIL_FROM, FROM);
test_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(rcpt_list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,101 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
/* test case and code based on https://github.com/curl/curl/issues/2847 */
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static char g_Data[40 * 1024]; /* POST 40KB */
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
curlsocktype purpose)
{
#if defined(SOL_SOCKET) && defined(SO_SNDBUF)
int sndbufsize = 4 * 1024; /* 4KB send buffer */
(void) clientp;
(void) purpose;
setsockopt(curlfd, SOL_SOCKET, SO_SNDBUF,
(const char *)&sndbufsize, sizeof(sndbufsize));
#else
(void)clientp;
(void)curlfd;
(void)purpose;
#endif
return CURL_SOCKOPT_OK;
}
int test(char *URL)
{
CURLcode code;
CURLcode res;
struct curl_slist *pHeaderList = NULL;
CURL *curl = curl_easy_init();
memset(g_Data, 'A', sizeof(g_Data)); /* send As! */
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, g_Data);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)sizeof(g_Data));
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 1;
test_setopt(curl, CURLOPT_DEBUGDATA, &libtest_debug_config);
test_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* Remove "Expect: 100-continue" */
pHeaderList = curl_slist_append(pHeaderList, "Expect:");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaderList);
code = curl_easy_perform(curl);
if(code == CURLE_OK) {
curl_off_t uploadSize;
curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD_T, &uploadSize);
printf("uploadSize = %ld\n", (long)uploadSize);
if((size_t) uploadSize == sizeof(g_Data)) {
printf("!!!!!!!!!! PASS\n");
}
else {
printf("sent %d, libcurl says %d\n",
(int)sizeof(g_Data), (int)uploadSize);
}
}
else {
printf("curl_easy_perform() failed. e = %d\n", code);
}
test_cleanup:
curl_slist_free_all(pHeaderList);
curl_easy_cleanup(curl);
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,87 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
/* test case and code based on https://github.com/curl/curl/issues/3927 */
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static int dload_progress_cb(void *a, curl_off_t b, curl_off_t c,
curl_off_t d, curl_off_t e)
{
(void)a;
(void)b;
(void)c;
(void)d;
(void)e;
return 0;
}
static size_t write_cb(char *d, size_t n, size_t l, void *p)
{
/* take care of the data here, ignored in this example */
(void)d;
(void)p;
return n*l;
}
static CURLcode run(CURL *hnd, long limit, long time)
{
curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_LIMIT, limit);
curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_TIME, time);
return curl_easy_perform(hnd);
}
int test(char *URL)
{
CURLcode ret;
CURL *hnd;
char buffer[CURL_ERROR_SIZE];
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, buffer);
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(hnd, CURLOPT_XFERINFOFUNCTION, dload_progress_cb);
printf("Start: %d\n", time(NULL));
ret = run(hnd, 1, 2);
if(ret)
fprintf(stderr, "error %d: %s\n", ret, buffer);
ret = run(hnd, 12000, 1);
if(ret != CURLE_OPERATION_TIMEDOUT)
fprintf(stderr, "error %d: %s\n", ret, buffer);
else
ret = CURLE_OK;
printf("End: %d\n", time(NULL));
curl_easy_cleanup(hnd);
curl_global_cleanup();
return (int)ret;
}

View file

@ -0,0 +1,100 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998, Vijay Panghal, <vpanghal@maginatics.com>, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* This unit test PUT http data over proxy. Proxy header will be different
* from server http header
*/
#include "test.h"
#include "memdebug.h"
static char data [] = "Hello Cloud!\n";
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
if(amount < strlen(data)) {
return strlen(data);
}
(void)stream;
memcpy(ptr, data, strlen(data));
return strlen(data);
}
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http and proxy header list*/
struct curl_slist *hhl = 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;
}
hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
if(!hhl) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_PROXYHEADER, hhl);
test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
test_setopt(curl, CURLOPT_POST, 0L);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(hhl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,105 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, Vijay Panghal, <vpanghal@maginatics.com>, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* This unit test PUT http data over proxy. Proxy header will be different
* from server http header
*/
#include "test.h"
#include "memdebug.h"
static char data [] = "Hello Cloud!\n";
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
if(amount < strlen(data)) {
return strlen(data);
}
(void)stream;
memcpy(ptr, data, strlen(data));
return strlen(data);
}
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http and proxy header list*/
struct curl_slist *hhl = NULL, *phl = NULL, *tmp = 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;
}
hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
phl = curl_slist_append(phl, "User-Agent: Proxy Agent");
if(!hhl || !phl) {
goto test_cleanup;
}
tmp = curl_slist_append(phl, "Expect:");
if(!tmp) {
goto test_cleanup;
}
phl = tmp;
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_PROXYHEADER, phl);
test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
test_setopt(curl, CURLOPT_POST, 0L);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(hhl);
curl_slist_free_all(phl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,102 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, Vijay Panghal, <vpanghal@maginatics.com>, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* This unit test PUT http data over proxy. Same http header will be generated
* for server and proxy
*/
#include "test.h"
#include "memdebug.h"
static char data [] = "Hello Cloud!\n";
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
if(amount < strlen(data)) {
return strlen(data);
}
(void)stream;
memcpy(ptr, data, strlen(data));
return strlen(data);
}
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http header list*/
struct curl_slist *hhl = NULL, *tmp = 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;
}
hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
if(!hhl) {
goto test_cleanup;
}
tmp = curl_slist_append(hhl, "Expect: 100-continue");
if(!tmp) {
goto test_cleanup;
}
hhl = tmp;
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_POST, 0L);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(hhl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,75 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http header list*/
struct curl_slist *hhl = NULL;
struct curl_slist *phl = 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;
}
hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
phl = curl_slist_append(phl, "Proxy-User-Agent: Http Agent2");
if(!hhl) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_PROXYHEADER, phl);
test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(hhl);
curl_slist_free_all(phl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,63 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
char bURL[512];
msnprintf(bURL, sizeof(bURL),
"%s HTTP/1.1\r\nGET http://1529.com/1529", URL);
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;
}
test_setopt(curl, CURLOPT_URL, bURL);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,70 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static curl_socket_t opensocket(void *clientp,
curlsocktype purpose,
struct curl_sockaddr *address)
{
(void)purpose;
(void)address;
(void)clientp;
fprintf(stderr, "opensocket() returns CURL_SOCKET_BAD\n");
return CURL_SOCKET_BAD;
}
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
(void)URL;
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;
}
test_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,160 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "timediff.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
static char const testData[] = ".abc\0xyz";
static off_t const testDataSize = sizeof(testData) - 1;
int test(char *URL)
{
CURL *easy;
CURLM *multi_handle;
int still_running; /* keep number of running handles */
CURLMsg *msg; /* for picking up messages with the transfer status */
int msgs_left; /* how many messages are left */
int res = CURLE_OK;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
/* Allocate one CURL handle per transfer */
easy = curl_easy_init();
/* init a multi stack */
multi_handle = curl_multi_init();
/* add the individual transfer */
curl_multi_add_handle(multi_handle, easy);
/* set the options (I left out a few, you'll get the point anyway) */
curl_easy_setopt(easy, CURLOPT_URL, URL);
curl_easy_setopt(easy, CURLOPT_POSTFIELDSIZE_LARGE,
(curl_off_t)testDataSize);
curl_easy_setopt(easy, CURLOPT_POSTFIELDS, testData);
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);
abort_on_test_timeout();
do {
struct timeval timeout;
int rc; /* select() return code */
CURLMcode mc; /* curl_multi_fdset() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -1;
long curl_timeo = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_timeout(multi_handle, &curl_timeo);
if(curl_timeo >= 0) {
curlx_mstotv(&timeout, curl_timeo);
if(timeout.tv_sec > 1) {
timeout.tv_sec = 1;
timeout.tv_usec = 0;
}
}
/* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) {
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break;
}
/* On success the value of maxfd is guaranteed to be >= -1. We call
select(maxfd + 1, ...); specially in case of (maxfd == -1) there are
no fds ready yet so we call select(0, ...) --or Sleep() on Windows--
to sleep 100ms, which is the minimum suggested value in the
curl_multi_fdset() doc. */
if(maxfd == -1) {
#if defined(WIN32) || defined(_WIN32)
Sleep(100);
rc = 0;
#else
/* Portable sleep for platforms other than Windows. */
struct timeval wait = { 0, 100 * 1000 }; /* 100ms */
rc = select(0, NULL, NULL, NULL, &wait);
#endif
}
else {
/* Note that on some platforms 'timeout' may be modified by select().
If you need access to the original value save a copy beforehand. */
rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
}
switch(rc) {
case -1:
/* select error */
break;
case 0: /* timeout */
default: /* action */
curl_multi_perform(multi_handle, &still_running);
break;
}
abort_on_test_timeout();
} while(still_running);
/* See how the transfers went */
do {
msg = curl_multi_info_read(multi_handle, &msgs_left);
if(msg && msg->msg == CURLMSG_DONE) {
printf("HTTP transfer completed with status %d\n", msg->data.result);
break;
}
abort_on_test_timeout();
} while(msg);
test_cleanup:
curl_multi_cleanup(multi_handle);
/* Free the CURL handles */
curl_easy_cleanup(easy);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,82 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test CURLINFO_RESPONSE_CODE */
int test(char *URL)
{
CURL *curl;
long httpcode;
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpcode);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(httpcode != 200) {
fprintf(stderr, "%s:%d unexpected response code %ld\n",
__FILE__, __LINE__, httpcode);
res = CURLE_HTTP_RETURNED_ERROR;
goto test_cleanup;
}
/* Test for a regression of github bug 1017 (response code does not reset) */
curl_easy_reset(curl);
res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpcode);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(httpcode) {
fprintf(stderr, "%s:%d curl_easy_reset failed to zero the response code\n"
"possible regression of github bug 1017\n", __FILE__, __LINE__);
res = CURLE_HTTP_RETURNED_ERROR;
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,201 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* This test sends data with CURLOPT_KEEP_SENDING_ON_ERROR.
* The server responds with an early error response.
* The test is successful if the connection can be reused for the next request,
* because this implies that the data has been sent completely to the server.
*/
#include "test.h"
#include "memdebug.h"
struct cb_data {
CURL *easy_handle;
int response_received;
int paused;
size_t remaining_bytes;
};
static void reset_data(struct cb_data *data, CURL *curl)
{
data->easy_handle = curl;
data->response_received = 0;
data->paused = 0;
data->remaining_bytes = 3;
}
static size_t read_callback(char *ptr, size_t size, size_t nitems,
void *userdata)
{
struct cb_data *data = (struct cb_data *)userdata;
/* wait until the server has sent all response headers */
if(data->response_received) {
size_t totalsize = nitems * size;
size_t bytes_to_send = data->remaining_bytes;
if(bytes_to_send > totalsize) {
bytes_to_send = totalsize;
}
memset(ptr, 'a', bytes_to_send);
data->remaining_bytes -= bytes_to_send;
return bytes_to_send;
}
else {
data->paused = 1;
return CURL_READFUNC_PAUSE;
}
}
static size_t write_callback(char *ptr, size_t size, size_t nmemb,
void *userdata)
{
struct cb_data *data = (struct cb_data *)userdata;
size_t totalsize = nmemb * size;
/* unused parameter */
(void)ptr;
/* all response headers have been received */
data->response_received = 1;
if(data->paused) {
/* continue to send request body data */
data->paused = 0;
curl_easy_pause(data->easy_handle, CURLPAUSE_CONT);
}
return totalsize;
}
static int perform_and_check_connections(CURL *curl, const char *description,
long expected_connections)
{
CURLcode res;
long connections = 0;
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed\n");
return TEST_ERR_MAJOR_BAD;
}
res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connections);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_getinfo() failed\n");
return TEST_ERR_MAJOR_BAD;
}
fprintf(stderr, "%s: expected: %ld connections; actual: %ld connections\n",
description, expected_connections, connections);
if(connections != expected_connections) {
return TEST_ERR_FAILURE;
}
return TEST_ERR_SUCCESS;
}
int test(char *URL)
{
struct cb_data data;
CURL *curl = NULL;
int res = TEST_ERR_FAILURE;
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;
}
reset_data(&data, curl);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_POST, 1L);
test_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
(curl_off_t)data.remaining_bytes);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_READDATA, &data);
test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
test_setopt(curl, CURLOPT_WRITEDATA, &data);
res = perform_and_check_connections(curl,
"First request without CURLOPT_KEEP_SENDING_ON_ERROR", 1);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
reset_data(&data, curl);
res = perform_and_check_connections(curl,
"Second request without CURLOPT_KEEP_SENDING_ON_ERROR", 1);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_KEEP_SENDING_ON_ERROR, 1L);
reset_data(&data, curl);
res = perform_and_check_connections(curl,
"First request with CURLOPT_KEEP_SENDING_ON_ERROR", 1);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
reset_data(&data, curl);
res = perform_and_check_connections(curl,
"Second request with CURLOPT_KEEP_SENDING_ON_ERROR", 0);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
res = TEST_ERR_SUCCESS;
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,131 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test CURLINFO_FILETIME */
int test(char *URL)
{
CURL *curl, *dupe = NULL;
long filetime;
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
/* Test that a filetime is properly initialized on curl_easy_init.
*/
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(filetime != -1) {
fprintf(stderr, "%s:%d filetime init failed; expected -1 but is %ld\n",
__FILE__, __LINE__, filetime);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_FILETIME, 1L);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
/* Test that a filetime is properly set after receiving an HTTP resource.
*/
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(filetime != 30) {
fprintf(stderr, "%s:%d filetime of http resource is incorrect; "
"expected 30 but is %ld\n",
__FILE__, __LINE__, filetime);
res = CURLE_HTTP_RETURNED_ERROR;
goto test_cleanup;
}
/* Test that a filetime is properly initialized on curl_easy_duphandle.
*/
dupe = curl_easy_duphandle(curl);
if(!dupe) {
fprintf(stderr, "%s:%d curl_easy_duphandle() failed\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
res = curl_easy_getinfo(dupe, CURLINFO_FILETIME, &filetime);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(filetime != -1) {
fprintf(stderr, "%s:%d filetime init failed; expected -1 but is %ld\n",
__FILE__, __LINE__, filetime);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
/* Test that a filetime is properly initialized on curl_easy_reset.
*/
curl_easy_reset(curl);
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(filetime != -1) {
fprintf(stderr, "%s:%d filetime init failed; expected -1 but is %ld\n",
__FILE__, __LINE__, filetime);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_easy_cleanup(dupe);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,130 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test CURLINFO_PROTOCOL */
int test(char *URL)
{
CURL *curl, *dupe = NULL;
long protocol;
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
/* Test that protocol is properly initialized on curl_easy_init.
*/
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol) {
fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
__FILE__, __LINE__, protocol);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
/* Test that a protocol is properly set after receiving an HTTP resource.
*/
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol != CURLPROTO_HTTP) {
fprintf(stderr, "%s:%d protocol of http resource is incorrect; "
"expected %d but is %ld\n",
__FILE__, __LINE__, CURLPROTO_HTTP, protocol);
res = CURLE_HTTP_RETURNED_ERROR;
goto test_cleanup;
}
/* Test that a protocol is properly initialized on curl_easy_duphandle.
*/
dupe = curl_easy_duphandle(curl);
if(!dupe) {
fprintf(stderr, "%s:%d curl_easy_duphandle() failed\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
res = curl_easy_getinfo(dupe, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol) {
fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
__FILE__, __LINE__, protocol);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
/* Test that a protocol is properly initialized on curl_easy_reset.
*/
curl_easy_reset(curl);
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol) {
fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
__FILE__, __LINE__, protocol);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_easy_cleanup(dupe);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,131 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test CURLINFO_SCHEME */
int test(char *URL)
{
CURL *curl, *dupe = NULL;
char *scheme;
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
/* Test that scheme is properly initialized on curl_easy_init.
*/
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(scheme) {
fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
/* Test that a scheme is properly set after receiving an HTTP resource.
*/
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(!scheme || memcmp(scheme, "HTTP", 5) != 0) {
fprintf(stderr, "%s:%d scheme of http resource is incorrect; "
"expected 'HTTP' but is %s\n",
__FILE__, __LINE__,
(scheme == NULL ? "NULL" : "invalid"));
res = CURLE_HTTP_RETURNED_ERROR;
goto test_cleanup;
}
/* Test that a scheme is properly initialized on curl_easy_duphandle.
*/
dupe = curl_easy_duphandle(curl);
if(!dupe) {
fprintf(stderr, "%s:%d curl_easy_duphandle() failed\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
res = curl_easy_getinfo(dupe, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(scheme) {
fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
/* Test that a scheme is properly initialized on curl_easy_reset.
*/
curl_easy_reset(curl);
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(scheme) {
fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_easy_cleanup(dupe);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,91 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7};
CURLcode res = CURLE_OK;
char *ptr = NULL;
int asize;
int outlen = 0;
char *raw;
(void)URL; /* we don't use this */
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
asize = (int)sizeof(a);
ptr = curl_easy_escape(NULL, (char *)a, asize);
printf("%s\n", ptr);
curl_free(ptr);
/* deprecated API */
ptr = curl_escape((char *)a, asize);
if(!ptr) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
printf("%s\n", ptr);
raw = curl_easy_unescape(NULL, ptr, (int)strlen(ptr), &outlen);
printf("outlen == %d\n", outlen);
printf("unescape == original? %s\n",
memcmp(raw, a, outlen) ? "no" : "YES");
curl_free(raw);
/* deprecated API */
raw = curl_unescape(ptr, (int)strlen(ptr));
if(!raw) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
outlen = (int)strlen(raw);
printf("[old] outlen == %d\n", outlen);
printf("[old] unescape == original? %s\n",
memcmp(raw, a, outlen) ? "no" : "YES");
curl_free(raw);
curl_free(ptr);
/* weird input length */
ptr = curl_easy_escape(NULL, (char *)a, -1);
printf("escape -1 length: %s\n", ptr);
/* weird input length */
outlen = 2017; /* just a value */
ptr = curl_easy_unescape(NULL, (char *)"moahahaha", -1, &outlen);
printf("unescape -1 length: %s %d\n", ptr, outlen);
test_cleanup:
curl_free(ptr);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,60 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
int res = 0;
CURLcode easyret;
CURLMcode multiret;
CURLSHcode shareret;
CURLUcode urlret;
(void)URL;
curl_easy_strerror((CURLcode)INT_MAX);
curl_multi_strerror((CURLMcode)INT_MAX);
curl_share_strerror((CURLSHcode)INT_MAX);
curl_url_strerror((CURLUcode)INT_MAX);
curl_easy_strerror((CURLcode)-INT_MAX);
curl_multi_strerror((CURLMcode)-INT_MAX);
curl_share_strerror((CURLSHcode)-INT_MAX);
curl_url_strerror((CURLUcode)-INT_MAX);
for(easyret = CURLE_OK; easyret <= CURL_LAST; easyret++) {
printf("e%d: %s\n", (int)easyret, curl_easy_strerror(easyret));
}
for(multiret = CURLM_CALL_MULTI_PERFORM; multiret <= CURLM_LAST;
multiret++) {
printf("m%d: %s\n", (int)multiret, curl_multi_strerror(multiret));
}
for(shareret = CURLSHE_OK; shareret <= CURLSHE_LAST; shareret++) {
printf("s%d: %s\n", (int)shareret, curl_share_strerror(shareret));
}
for(urlret = CURLUE_OK; urlret <= CURLUE_LAST; urlret++) {
printf("u%d: %s\n", (int)urlret, curl_url_strerror(urlret));
}
return (int)res;
}

View file

@ -0,0 +1,121 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct transfer_status {
CURL *easy;
int halted;
int counter; /* count write callback invokes */
int please; /* number of times xferinfo is called while halted */
};
static int please_continue(void *userp,
curl_off_t dltotal,
curl_off_t dlnow,
curl_off_t ultotal,
curl_off_t ulnow)
{
struct transfer_status *st = (struct transfer_status *)userp;
(void)dltotal;
(void)dlnow;
(void)ultotal;
(void)ulnow;
if(st->halted) {
st->please++;
if(st->please == 2) {
/* waited enough, unpause! */
curl_easy_pause(st->easy, CURLPAUSE_CONT);
}
}
fprintf(stderr, "xferinfo: paused %d\n", st->halted);
return 0; /* go on */
}
static size_t header_callback(void *ptr, size_t size, size_t nmemb,
void *userp)
{
size_t len = size * nmemb;
(void)userp;
(void)fwrite(ptr, size, nmemb, stdout);
return len;
}
static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *userp)
{
struct transfer_status *st = (struct transfer_status *)userp;
size_t len = size * nmemb;
st->counter++;
if(st->counter > 1) {
/* the first call puts us on pause, so subsequent calls are after
unpause */
fwrite(ptr, size, nmemb, stdout);
return len;
}
printf("Got %d bytes but pausing!\n", (int)len);
st->halted = 1;
return CURL_WRITEFUNC_PAUSE;
}
int test(char *URL)
{
CURL *curls = NULL;
int i = 0;
int res = 0;
struct transfer_status st;
start_test_timing();
memset(&st, 0, sizeof(st));
global_init(CURL_GLOBAL_ALL);
easy_init(curls);
st.easy = curls; /* to allow callbacks access */
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback);
easy_setopt(curls, CURLOPT_WRITEDATA, &st);
easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback);
easy_setopt(curls, CURLOPT_HEADERDATA, &st);
easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, please_continue);
easy_setopt(curls, CURLOPT_XFERINFODATA, &st);
easy_setopt(curls, CURLOPT_NOPROGRESS, 0L);
res = curl_easy_perform(curls);
test_cleanup:
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}

View file

@ -0,0 +1,88 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* Test CURLOPT_MAXLIFETIME_CONN:
* Send four requests, sleeping between the second and third and setting
* MAXLIFETIME_CONN between the third and fourth. The first three requests
* should use the same connection, and the fourth request should close the
* first connection and open a second.
*/
#include "test.h"
#include "testutil.h"
#include "testtrace.h"
#include "warnless.h"
#include "memdebug.h"
#if defined(WIN32) || defined(_WIN32)
#define sleep(sec) Sleep ((sec)*1000)
#endif
int test(char *URL)
{
CURL *easy = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
res_easy_init(easy);
easy_setopt(easy, CURLOPT_URL, URL);
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 0;
easy_setopt(easy, CURLOPT_DEBUGDATA, &libtest_debug_config);
easy_setopt(easy, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
easy_setopt(easy, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
/* CURLOPT_MAXLIFETIME_CONN is inclusive - the connection needs to be 2
* seconds old */
sleep(2);
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
easy_setopt(easy, CURLOPT_MAXLIFETIME_CONN, 1L);
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
test_cleanup:
curl_easy_cleanup(easy);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,48 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
#include <curl/multi.h>
int test(char *URL)
{
CURLM *handle;
int res = CURLE_OK;
static const char * const bl_servers[] =
{"Microsoft-IIS/6.0", "nginx/0.8.54", NULL};
static const char * const bl_sites[] =
{"curl.se:443", "example.com:80", NULL};
global_init(CURL_GLOBAL_ALL);
handle = curl_multi_init();
(void)URL; /* unused */
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SERVER_BL, bl_servers);
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SITE_BL, bl_sites);
curl_multi_cleanup(handle);
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,49 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
#include <curl/multi.h>
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
fprintf(stderr, "****************************** Do it again\n");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,95 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *curls = NULL;
CURLM *multi = NULL;
int still_running;
int i = 0;
int res = 0;
CURLMsg *msg;
int counter = 3;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
easy_setopt(curls, CURLOPT_VERBOSE, 1L);
easy_setopt(curls, CURLOPT_USERPWD, "u:s");
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running && counter--) {
int num;
res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
if(res != CURLM_OK) {
printf("curl_multi_wait() returned %d\n", res);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}

View file

@ -0,0 +1,111 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
static int xferinfo(void *p,
curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow)
{
(void)p;
(void)dlnow;
(void)dltotal;
(void)ulnow;
(void)ultotal;
fprintf(stderr, "xferinfo fail!\n");
return 1; /* fail as fast as we can */
}
int test(char *URL)
{
CURL *curls = NULL;
CURLM *multi = NULL;
int still_running;
int i = 0;
int res = 0;
curl_mimepart *field = NULL;
curl_mime *mime = NULL;
int counter = 1;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
mime = curl_mime_init(curls);
field = curl_mime_addpart(mime);
curl_mime_name(field, "name");
curl_mime_data(field, "value", CURL_ZERO_TERMINATED);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
easy_setopt(curls, CURLOPT_VERBOSE, 1L);
easy_setopt(curls, CURLOPT_MIMEPOST, mime);
easy_setopt(curls, CURLOPT_USERPWD, "u:s");
easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, xferinfo);
easy_setopt(curls, CURLOPT_NOPROGRESS, 1L);
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running && counter--) {
int num;
res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
if(res != CURLM_OK) {
printf("curl_multi_wait() returned %d\n", res);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
test_cleanup:
curl_mime_free(mime);
curl_multi_remove_handle(multi, curls);
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}

View file

@ -0,0 +1,92 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static void my_lock(CURL *handle, curl_lock_data data,
curl_lock_access laccess, void *useptr)
{
(void)handle;
(void)data;
(void)laccess;
(void)useptr;
printf("-> Mutex lock\n");
}
static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
(void)handle;
(void)data;
(void)useptr;
printf("<- Mutex unlock\n");
}
/* test function */
int test(char *URL)
{
CURLcode res = CURLE_OK;
CURLSH *share;
int i;
global_init(CURL_GLOBAL_ALL);
share = curl_share_init();
if(!share) {
fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
/* Loop the transfer and cleanup the handle properly every lap. This will
still reuse connections since the pool is in the shared object! */
for(i = 0; i < 3; i++) {
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, URL);
/* use the share object */
curl_easy_setopt(curl, CURLOPT_SHARE, share);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
}
curl_share_cleanup(share);
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,81 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* Verify that some API functions are locked from being called inside callback
*/
#include "test.h"
#include "memdebug.h"
static CURL *curl;
static int progressCallback(void *arg,
double dltotal,
double dlnow,
double ultotal,
double ulnow)
{
CURLcode res = CURLE_OK;
char buffer[256];
size_t n = 0;
(void)arg;
(void)dltotal;
(void)dlnow;
(void)ultotal;
(void)ulnow;
res = curl_easy_recv(curl, buffer, 256, &n);
printf("curl_easy_recv returned %d\n", res);
res = curl_easy_send(curl, buffer, n, &n);
printf("curl_easy_send returned %d\n", res);
return 1;
}
int test(char *URL)
{
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_TIMEOUT, (long)7);
easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
res = curl_easy_perform(curl);
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,80 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct headerinfo {
size_t largest;
};
static size_t header(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t headersize = size * nmemb;
struct headerinfo *info = (struct headerinfo *)stream;
(void)ptr;
if(headersize > info->largest)
/* remember the longest header */
info->largest = headersize;
return nmemb * size;
}
int test(char *URL)
{
CURLcode code;
CURL *curl = NULL;
int res = 0;
struct headerinfo info = {0};
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_HEADERFUNCTION, header);
easy_setopt(curl, CURLOPT_HEADERDATA, &info);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_URL, URL);
code = curl_easy_perform(curl);
if(CURLE_OK != code) {
fprintf(stderr, "%s:%d curl_easy_perform() failed, "
"with code %d (%s)\n",
__FILE__, __LINE__, (int)code, curl_easy_strerror(code));
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
printf("Max = %ld\n", (long)info.largest);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,64 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLM *curlm = NULL;
CURL *curl1 = NULL;
CURL *curl2 = NULL;
int running_handles = 0;
int res = 0;
global_init(CURL_GLOBAL_ALL);
multi_init(curlm);
multi_setopt(curlm, CURLMOPT_MAX_HOST_CONNECTIONS, 1);
easy_init(curl1);
easy_setopt(curl1, CURLOPT_URL, URL);
multi_add_handle(curlm, curl1);
easy_init(curl2);
easy_setopt(curl2, CURLOPT_URL, URL);
multi_add_handle(curlm, curl2);
multi_perform(curlm, &running_handles);
multi_remove_handle(curlm, curl2);
/* If curl2 is still in the connect-pending list, this will crash */
multi_remove_handle(curlm, curl1);
test_cleanup:
curl_easy_cleanup(curl1);
curl_easy_cleanup(curl2);
curl_multi_cleanup(curlm);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,67 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res = CURLE_OK;
CURL *curl = NULL;
long protocol = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "curl_easy_perform() returned %d (%s)\n",
res, curl_easy_strerror(res));
goto test_cleanup;
}
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "curl_easy_getinfo() returned %d (%s)\n",
res, curl_easy_strerror(res));
goto test_cleanup;
}
printf("Protocol: %lx\n", protocol);
curl_easy_cleanup(curl);
curl_global_cleanup();
return 0;
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res; /* return the final return code */
}

View file

@ -0,0 +1,76 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define EXCESSIVE 10*1000*1000
int test(char *URL)
{
CURLcode res = CURLE_OK;
CURL *curl = NULL;
char *longurl = malloc(EXCESSIVE);
CURLU *u;
(void)URL;
if(!longurl)
return 1;
memset(longurl, 'a', EXCESSIVE);
longurl[EXCESSIVE-1] = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
res = curl_easy_setopt(curl, CURLOPT_URL, longurl);
printf("CURLOPT_URL %d bytes URL == %d\n",
EXCESSIVE, (int)res);
res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, longurl);
printf("CURLOPT_POSTFIELDS %d bytes data == %d\n",
EXCESSIVE, (int)res);
u = curl_url();
if(u) {
CURLUcode uc = curl_url_set(u, CURLUPART_URL, longurl, 0);
printf("CURLUPART_URL %d bytes URL == %d (%s)\n",
EXCESSIVE, (int)uc, curl_url_strerror(uc));
uc = curl_url_set(u, CURLUPART_SCHEME, longurl, CURLU_NON_SUPPORT_SCHEME);
printf("CURLUPART_SCHEME %d bytes scheme == %d (%s)\n",
EXCESSIVE, (int)uc, curl_url_strerror(uc));
uc = curl_url_set(u, CURLUPART_USER, longurl, 0);
printf("CURLUPART_USER %d bytes user == %d (%s)\n",
EXCESSIVE, (int)uc, curl_url_strerror(uc));
curl_url_cleanup(u);
}
test_cleanup:
free(longurl);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res; /* return the final return code */
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,135 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define WAKEUP_NUM 10
int test(char *URL)
{
CURLM *multi = NULL;
int numfds;
int i;
int res = 0;
struct timeval time_before_wait, time_after_wait;
(void)URL;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
/* no wakeup */
time_before_wait = tutil_tvnow();
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = tutil_tvnow();
if(tutil_tvdiff(time_after_wait, time_before_wait) < 500) {
fprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
/* try a single wakeup */
res_multi_wakeup(multi);
time_before_wait = tutil_tvnow();
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = tutil_tvnow();
if(tutil_tvdiff(time_after_wait, time_before_wait) > 500) {
fprintf(stderr, "%s:%d curl_multi_poll returned too late\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
/* previous wakeup should not wake up this */
time_before_wait = tutil_tvnow();
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = tutil_tvnow();
if(tutil_tvdiff(time_after_wait, time_before_wait) < 500) {
fprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
/* try lots of wakeup */
for(i = 0; i < WAKEUP_NUM; ++i)
res_multi_wakeup(multi);
time_before_wait = tutil_tvnow();
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = tutil_tvnow();
if(tutil_tvdiff(time_after_wait, time_before_wait) > 500) {
fprintf(stderr, "%s:%d curl_multi_poll returned too late\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
/* Even lots of previous wakeups should not wake up this. */
time_before_wait = tutil_tvnow();
multi_poll(multi, NULL, 0, 1000, &numfds);
time_after_wait = tutil_tvnow();
if(tutil_tvdiff(time_after_wait, time_before_wait) < 500) {
fprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
__FILE__, __LINE__);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
test_cleanup:
curl_multi_cleanup(multi);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,209 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#include <unistd.h>
#define TEST_HANG_TIMEOUT 60 * 1000
#define CONN_NUM 3
#define TIME_BETWEEN_START_SECS 2
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static CURL *pending_handles[CONN_NUM];
static int pending_num = 0;
static int test_failure = 0;
static CURLM *multi = NULL;
static const char *url;
static void *run_thread(void *ptr)
{
CURL *easy = NULL;
int res = 0;
int i;
(void)ptr;
for(i = 0; i < CONN_NUM; i++) {
wait_ms(TIME_BETWEEN_START_SECS * 1000);
easy_init(easy);
easy_setopt(easy, CURLOPT_URL, url);
easy_setopt(easy, CURLOPT_VERBOSE, 0L);
pthread_mutex_lock(&lock);
if(test_failure) {
pthread_mutex_unlock(&lock);
goto test_cleanup;
}
pending_handles[pending_num] = easy;
pending_num++;
easy = NULL;
pthread_mutex_unlock(&lock);
res_multi_wakeup(multi);
}
test_cleanup:
curl_easy_cleanup(easy);
pthread_mutex_lock(&lock);
if(!test_failure)
test_failure = res;
pthread_mutex_unlock(&lock);
return NULL;
}
int test(char *URL)
{
int still_running;
int num;
int i;
int res = 0;
CURL *started_handles[CONN_NUM];
int started_num = 0;
int finished_num = 0;
pthread_t tid;
bool tid_valid = false;
struct CURLMsg *message;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
url = URL;
res = pthread_create(&tid, NULL, run_thread, NULL);
if(!res)
tid_valid = true;
else {
fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n",
__FILE__, __LINE__, res);
goto test_cleanup;
}
while(1) {
multi_perform(multi, &still_running);
abort_on_test_timeout();
while((message = curl_multi_info_read(multi, &num))) {
if(message->msg == CURLMSG_DONE) {
res = message->data.result;
if(res)
goto test_cleanup;
multi_remove_handle(multi, message->easy_handle);
finished_num++;
}
else {
fprintf(stderr, "%s:%d Got an unexpected message from curl: %i\n",
__FILE__, __LINE__, (int)message->msg);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
}
if(CONN_NUM == finished_num)
break;
multi_poll(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
abort_on_test_timeout();
pthread_mutex_lock(&lock);
while(pending_num > 0) {
res_multi_add_handle(multi, pending_handles[pending_num - 1]);
if(res) {
pthread_mutex_unlock(&lock);
goto test_cleanup;
}
started_handles[started_num] = pending_handles[pending_num - 1];
started_num++;
pending_num--;
}
pthread_mutex_unlock(&lock);
abort_on_test_timeout();
}
if(CONN_NUM != started_num) {
fprintf(stderr, "%s:%d Not all connections started: %d of %d\n",
__FILE__, __LINE__, started_num, CONN_NUM);
goto test_cleanup;
}
if(CONN_NUM != finished_num) {
fprintf(stderr, "%s:%d Not all connections finished: %d of %d\n",
__FILE__, __LINE__, started_num, CONN_NUM);
goto test_cleanup;
}
test_cleanup:
pthread_mutex_lock(&lock);
if(!test_failure)
test_failure = res;
pthread_mutex_unlock(&lock);
if(tid_valid)
pthread_join(tid, NULL);
curl_multi_cleanup(multi);
for(i = 0; i < pending_num; i++)
curl_easy_cleanup(pending_handles[i]);
for(i = 0; i < started_num; i++)
curl_easy_cleanup(started_handles[i]);
curl_global_cleanup();
return test_failure;
}
#else /* without pthread, this test doesn't work */
int test(char *URL)
{
(void)URL;
return 0;
}
#endif

View file

@ -0,0 +1,54 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
#include <curl/multi.h>
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
CURLU *u = curl_url();
if(u) {
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_url_set(u, CURLUPART_URL, URL, 0);
curl_easy_setopt(curl, CURLOPT_CURLU, u);
res = curl_easy_perform(curl);
fprintf(stderr, "****************************** Do it again\n");
res = curl_easy_perform(curl);
curl_url_cleanup(u);
}
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,52 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2021 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret;
CURL *hnd;
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
curl_easy_setopt(hnd, CURLOPT_USERPWD, "testuser:testpass");
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "lib1568");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_PORT, (long)atoi(libtest_arg2));
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
hnd = NULL;
curl_global_cleanup();
return (int)ret;
}

View file

@ -0,0 +1,48 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2021 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret;
CURL *hnd;
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
ret = curl_easy_perform(hnd);
curl_easy_setopt(hnd, CURLOPT_URL, libtest_arg2);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
curl_global_cleanup();
return (int)ret;
}

View file

@ -0,0 +1,120 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* This unit test PUT http data over proxy. Proxy header will be different
* from server http header
*/
#include "test.h"
#include <stdio.h>
#include "memdebug.h"
static char data [] = "Hello Cloud!\r\n";
static size_t consumed = 0;
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
if(consumed == strlen(data)) {
return 0;
}
if(amount > strlen(data)-consumed) {
amount = strlen(data);
}
consumed += amount;
(void)stream;
memcpy(ptr, data, amount);
return amount;
}
/*
* carefully not leak memory on OOM
*/
static int trailers_callback(struct curl_slist **list, void *userdata)
{
struct curl_slist *nlist = NULL;
struct curl_slist *nlist2 = NULL;
(void)userdata;
nlist = curl_slist_append(*list, "my-super-awesome-trailer: trail1");
if(nlist)
nlist2 = curl_slist_append(nlist, "my-other-awesome-trailer: trail2");
if(nlist2) {
*list = nlist2;
return CURL_TRAILERFUNC_OK;
}
else {
curl_slist_free_all(nlist);
return CURL_TRAILERFUNC_ABORT;
}
}
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http and proxy header list*/
struct curl_slist *hhl = 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;
}
hhl = curl_slist_append(hhl, "Trailer: my-super-awesome-trailer,"
" my-other-awesome-trailer");
if(!hhl) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_PUT, 1L);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_TRAILERFUNCTION, trailers_callback);
test_setopt(curl, CURLOPT_TRAILERDATA, NULL);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(hhl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,123 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/*
* See https://github.com/curl/curl/issues/3371
*
* This test case checks whether curl_multi_remove_handle() cancels
* asynchronous DNS resolvers without blocking where possible. Obviously, it
* only tests whichever resolver cURL is actually built with.
*/
/* We're willing to wait a very generous two seconds for the removal. This is
as low as we can go while still easily supporting SIGALRM timing for the
non-threaded blocking resolver. It doesn't matter that much because when
the test passes, we never wait this long. */
#define TEST_HANG_TIMEOUT 2 * 1000
#include "test.h"
#include "testutil.h"
#include <sys/stat.h>
int test(char *URL)
{
int stillRunning;
CURLM *multiHandle = NULL;
CURL *curl = NULL;
CURLcode res = CURLE_OK;
CURLMcode mres;
int timeout;
global_init(CURL_GLOBAL_ALL);
multi_init(multiHandle);
easy_init(curl);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_URL, URL);
/* Set a DNS server that hopefully will not respond when using c-ares. */
if(curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, "0.0.0.0") == CURLE_OK)
/* Since we could set the DNS server, presume we are working with a
resolver that can be cancelled (i.e. c-ares). Thus,
curl_multi_remove_handle() should not block even when the resolver
request is outstanding. So, set a request timeout _longer_ than the
test hang timeout so we will fail if the handle removal call incorrectly
blocks. */
timeout = TEST_HANG_TIMEOUT * 2;
else {
/* If we can't set the DNS server, presume that we are configured to use a
resolver that can't be cancelled (i.e. the threaded resolver or the
non-threaded blocking resolver). So, we just test that the
curl_multi_remove_handle() call does finish well within our test
timeout.
But, it is very unlikely that the resolver request will take any time at
all because we haven't been able to configure the resolver to use an
non-responsive DNS server. At least we exercise the flow.
*/
fprintf(stderr,
"CURLOPT_DNS_SERVERS not supported; "
"assuming curl_multi_remove_handle() will block\n");
timeout = TEST_HANG_TIMEOUT / 2;
}
/* Setting a timeout on the request should ensure that even if we have to
wait for the resolver during curl_multi_remove_handle(), it won't take
longer than this, because the resolver request inherits its timeout from
this. */
easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout);
multi_add_handle(multiHandle, curl);
/* This should move the handle from INIT => CONNECT => WAITRESOLVE. */
fprintf(stderr, "curl_multi_perform()...\n");
multi_perform(multiHandle, &stillRunning);
fprintf(stderr, "curl_multi_perform() succeeded\n");
/* Start measuring how long it takes to remove the handle. */
fprintf(stderr, "curl_multi_remove_handle()...\n");
start_test_timing();
mres = curl_multi_remove_handle(multiHandle, curl);
if(mres) {
fprintf(stderr, "curl_multi_remove_handle() failed, "
"with code %d\n", (int)res);
res = TEST_ERR_MULTI;
goto test_cleanup;
}
fprintf(stderr, "curl_multi_remove_handle() succeeded\n");
/* Fail the test if it took too long to remove. This happens after the fact,
and says "it seems that it would have run forever", which isn't true, but
it's close enough, and simple to do. */
abort_on_test_timeout();
test_cleanup:
curl_easy_cleanup(curl);
curl_multi_cleanup(multiHandle);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,81 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* Test suppressing the If-Modified-Since header */
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
struct curl_slist *header = NULL;
long unmet;
CURL *curl = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_TIMECONDITION, (long)CURL_TIMECOND_IFMODSINCE);
/* Some TIMEVALUE; it doesn't matter. */
easy_setopt(curl, CURLOPT_TIMEVALUE, 1566210680L);
header = curl_slist_append(NULL, "If-Modified-Since:");
if(!header) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
easy_setopt(curl, CURLOPT_HTTPHEADER, header);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* Confirm that the condition checking still worked, even though we
* suppressed the actual header.
* The server returns 304, which means the condition is "unmet".
*/
res = curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
if(res)
goto test_cleanup;
if(unmet != 1L) {
res = TEST_ERR_FAILURE;
goto test_cleanup;
}
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_slist_free_all(header);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,68 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* Testing Retry-After header parser */
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
struct curl_slist *header = NULL;
curl_off_t retry;
CURL *curl = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
res = curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry);
if(res)
goto test_cleanup;
#ifdef LIB1596
/* we get a relative number of seconds, so add the number of seconds
we're at to make it a somewhat stable number. Then remove accuracy. */
retry += time(NULL);
retry /= 10000;
#endif
printf("Retry-After %" CURL_FORMAT_CURL_OFF_T "\n", retry);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_slist_free_all(header);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,85 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
/* Testing CURLOPT_PROTOCOLS_STR */
#include "test.h"
#include "memdebug.h"
struct pair {
const char *in;
CURLcode exp;
};
int test(char *URL)
{
CURL *curl = NULL;
int res = 0;
CURLcode result = CURLE_OK;
int i;
struct pair prots[] = {
{"goobar", CURLE_BAD_FUNCTION_ARGUMENT},
{"http ", CURLE_BAD_FUNCTION_ARGUMENT},
{" http", CURLE_BAD_FUNCTION_ARGUMENT},
{"http", CURLE_OK},
{"http,", CURLE_OK},
{"https,", CURLE_OK},
{"https,http", CURLE_OK},
{"http,http", CURLE_OK},
{"HTTP,HTTP", CURLE_OK},
{",HTTP,HTTP", CURLE_OK},
{"http,http,ft", CURLE_BAD_FUNCTION_ARGUMENT},
{"", CURLE_BAD_FUNCTION_ARGUMENT},
{",,", CURLE_BAD_FUNCTION_ARGUMENT},
{"DICT,FILE,FTP,FTPS,GOPHER,GOPHERS,HTTP,HTTPS,IMAP,IMAPS,LDAP,LDAPS,"
"POP3,POP3S,RTMP,RTMPE,RTMPS,RTMPT,RTMPTE,RTMPTS,RTSP,SCP,SFTP,SMB,"
"SMBS,SMTP,SMTPS,TELNET,TFTP", CURLE_OK},
{"all", CURLE_OK},
{NULL, CURLE_OK},
};
(void)URL;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
for(i = 0; prots[i].in; i++) {
result = curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, prots[i].in);
if(result != prots[i].exp) {
printf("unexpectedly '%s' returned %u\n",
prots[i].in, result);
break;
}
}
printf("Tested %u strings\n", i);
res = (int)result;
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)result;
}

View file

@ -0,0 +1,100 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2019 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "timediff.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLSH *sh = NULL;
CURL *ch = NULL;
int unfinished;
CURLM *cm;
curl_global_init(CURL_GLOBAL_ALL);
cm = curl_multi_init();
if(!cm) {
curl_global_cleanup();
return 1;
}
sh = curl_share_init();
if(!sh)
goto cleanup;
curl_share_setopt(sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
curl_share_setopt(sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
ch = curl_easy_init();
if(!ch)
goto cleanup;
curl_easy_setopt(ch, CURLOPT_SHARE, sh);
curl_easy_setopt(ch, CURLOPT_URL, URL);
curl_easy_setopt(ch, CURLOPT_COOKIEFILE, "log/cookies1905");
curl_easy_setopt(ch, CURLOPT_COOKIEJAR, "log/cookies1905");
curl_multi_add_handle(cm, ch);
unfinished = 1;
while(unfinished) {
int MAX = 0;
long max_tout;
fd_set R, W, E;
struct timeval timeout;
FD_ZERO(&R);
FD_ZERO(&W);
FD_ZERO(&E);
curl_multi_perform(cm, &unfinished);
curl_multi_fdset(cm, &R, &W, &E, &MAX);
curl_multi_timeout(cm, &max_tout);
if(max_tout > 0) {
curlx_mstotv(&timeout, max_tout);
}
else {
timeout.tv_sec = 0;
timeout.tv_usec = 1000;
}
select(MAX + 1, &R, &W, &E, &timeout);
}
curl_easy_setopt(ch, CURLOPT_COOKIELIST, "FLUSH");
curl_easy_setopt(ch, CURLOPT_SHARE, NULL);
curl_multi_remove_handle(cm, ch);
cleanup:
curl_easy_cleanup(ch);
curl_share_cleanup(sh);
curl_multi_cleanup(cm);
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,74 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2019 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
char *url_after;
CURLU *curlu = curl_url();
CURL *curl = curl_easy_init();
CURLcode curl_code;
char error_buffer[CURL_ERROR_SIZE] = "";
curl_url_set(curlu, CURLUPART_URL, URL, CURLU_DEFAULT_SCHEME);
curl_easy_setopt(curl, CURLOPT_CURLU, curlu);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* set a port number that makes this reqeuest fail */
curl_easy_setopt(curl, CURLOPT_PORT, 1L);
curl_code = curl_easy_perform(curl);
if(!curl_code)
fprintf(stderr, "failure expected, "
"curl_easy_perform returned %ld: <%s>, <%s>\n",
(long) curl_code, curl_easy_strerror(curl_code), error_buffer);
/* print the used url */
curl_url_get(curlu, CURLUPART_URL, &url_after, 0);
fprintf(stderr, "curlu now: <%s>\n", url_after);
curl_free(url_after);
/* now reset CURLOP_PORT to go back to originally set port number */
curl_easy_setopt(curl, CURLOPT_PORT, 0L);
curl_code = curl_easy_perform(curl);
if(curl_code)
fprintf(stderr, "success expected, "
"curl_easy_perform returned %ld: <%s>, <%s>\n",
(long) curl_code, curl_easy_strerror(curl_code), error_buffer);
/* print url */
curl_url_get(curlu, CURLUPART_URL, &url_after, 0);
fprintf(stderr, "curlu now: <%s>\n", url_after);
curl_free(url_after);
curl_easy_cleanup(curl);
curl_url_cleanup(curlu);
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,56 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2019 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
char *url_after;
CURL *curl;
CURLcode curl_code;
char error_buffer[CURL_ERROR_SIZE] = "";
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_code = curl_easy_perform(curl);
if(!curl_code)
fprintf(stderr, "failure expected, "
"curl_easy_perform returned %ld: <%s>, <%s>\n",
(long) curl_code, curl_easy_strerror(curl_code), error_buffer);
/* print the used url */
if(!curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url_after))
printf("Effective URL: %s\n", url_after);
curl_easy_cleanup(curl);
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,64 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2022, Linus Nielsen Feltzing, <linus@haxx.se>
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret = CURLE_OK;
CURL *hnd;
start_test_timing();
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
if(hnd) {
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_ALTSVC, "log/altsvc-1908");
ret = curl_easy_perform(hnd);
if(!ret) {
/* make a copy and check that this also has alt-svc activated */
CURL *also = curl_easy_duphandle(hnd);
if(also) {
ret = curl_easy_perform(also);
/* we close the second handle first, which makes it store the alt-svc
file only to get overwritten when the next handle is closed! */
curl_easy_cleanup(also);
}
}
curl_easy_reset(hnd);
/* using the same file name for the alt-svc cache, this clobbers the
content just written from the 'also' handle */
curl_easy_cleanup(hnd);
}
curl_global_cleanup();
return (int)ret;
}

View file

@ -0,0 +1,49 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2022, Linus Nielsen Feltzing, <linus@haxx.se>
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret = CURLE_OK;
CURL *hnd;
start_test_timing();
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
if(hnd) {
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(hnd, CURLOPT_USERPWD, "user\nname:pass\nword");
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
}
curl_global_cleanup();
return (int)ret;
}

View file

@ -0,0 +1,95 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/* The maximum string length limit (CURL_MAX_INPUT_LENGTH) is an internal
define not publicly exposed so we set our own */
#define MAX_INPUT_LENGTH 8000000
static char buffer[MAX_INPUT_LENGTH + 2];
int test(char *URL)
{
const struct curl_easyoption *o;
CURL *easy;
int error = 0;
(void)URL;
curl_global_init(CURL_GLOBAL_ALL);
easy = curl_easy_init();
if(!easy) {
curl_global_cleanup();
return 1;
}
/* make it a zero terminated C string with just As */
memset(buffer, 'A', MAX_INPUT_LENGTH + 1);
buffer[MAX_INPUT_LENGTH + 1] = 0;
printf("string length: %d\n", (int)strlen(buffer));
for(o = curl_easy_option_next(NULL);
o;
o = curl_easy_option_next(o)) {
if(o->type == CURLOT_STRING) {
CURLcode result;
/*
* Whitelist string options that are safe for abuse
*/
switch(o->id) {
case CURLOPT_PROXY_TLSAUTH_TYPE:
case CURLOPT_TLSAUTH_TYPE:
case CURLOPT_RANDOM_FILE:
case CURLOPT_EGDSOCKET:
continue;
default:
/* check this */
break;
}
/* This is a string. Make sure that passing in a string longer
CURL_MAX_INPUT_LENGTH returns an error */
result = curl_easy_setopt(easy, o->id, buffer);
switch(result) {
case CURLE_BAD_FUNCTION_ARGUMENT: /* the most normal */
case CURLE_UNKNOWN_OPTION: /* left out from the build */
case CURLE_NOT_BUILT_IN: /* not supported */
break;
default:
/* all other return codes are unexpected */
fprintf(stderr, "curl_easy_setopt(%s...) returned %d\n",
o->name, (int)result);
error++;
break;
}
}
}
curl_easy_cleanup(easy);
curl_global_cleanup();
return error;
}

View file

@ -0,0 +1,82 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define print_err(name, exp) \
fprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", name, exp);
int test(char *URL)
{
/* Only test if GCC typechecking is available */
int error = 0;
#ifdef CURLINC_TYPECHECK_GCC_H
const struct curl_easyoption *o;
for(o = curl_easy_option_next(NULL);
o;
o = curl_easy_option_next(o)) {
/* Test for mismatch OR missing typecheck macros */
if(curlcheck_long_option(o->id) !=
(o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) {
print_err(o->name, "CURLOT_LONG or CURLOT_VALUES");
error++;
}
if(curlcheck_off_t_option(o->id) != (o->type == CURLOT_OFF_T)) {
print_err(o->name, "CURLOT_OFF_T");
error++;
}
if(curlcheck_string_option(o->id) != (o->type == CURLOT_STRING)) {
print_err(o->name, "CURLOT_STRING");
error++;
}
if(curlcheck_slist_option(o->id) != (o->type == CURLOT_SLIST)) {
print_err(o->name, "CURLOT_SLIST");
error++;
}
if(curlcheck_cb_data_option(o->id) != (o->type == CURLOT_CBPTR)) {
print_err(o->name, "CURLOT_CBPTR");
error++;
}
/* From here: only test that the type matches if macro is known */
if(curlcheck_write_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
print_err(o->name, "CURLOT_FUNCTION");
error++;
}
if(curlcheck_conv_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
print_err(o->name, "CURLOT_FUNCTION");
error++;
}
if(curlcheck_postfields_option(o->id) && (o->type != CURLOT_OBJECT)) {
print_err(o->name, "CURLOT_OBJECT");
error++;
}
/* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
}
#endif
(void)URL;
return error;
}

View file

@ -0,0 +1,50 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2020 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret = CURLE_OK;
CURL *hnd;
start_test_timing();
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
if(hnd) {
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_NOBODY, 1L);
if(libtest_arg2)
/* test1914 sets this extra arg */
curl_easy_setopt(hnd, CURLOPT_FILETIME, 1L);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
}
curl_global_cleanup();
return (int)ret;
}

View file

@ -0,0 +1,128 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2020 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct entry {
const char *name;
const char *exp;
};
static const struct entry preload_hosts[] = {
/* curl turns 39 that day just before 31-bit time_t overflow */
{ "1.example.com", "20370320 01:02:03" },
{ "2.example.com", "20370320 03:02:01" },
{ "3.example.com", "20370319 01:02:03" },
{ "4.example.com", "" },
{ NULL, NULL } /* end of list marker */
};
struct state {
int index;
};
/* "read" is from the point of the library, it wants data from us */
static CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *e,
void *userp)
{
const char *host;
const char *expire;
struct state *s = (struct state *)userp;
(void)easy;
host = preload_hosts[s->index].name;
expire = preload_hosts[s->index++].exp;
if(host && (strlen(host) < e->namelen)) {
strcpy(e->name, host);
e->includeSubDomains = FALSE;
strcpy(e->expire, expire);
fprintf(stderr, "add '%s'\n", host);
}
else
return CURLSTS_DONE;
return CURLSTS_OK;
}
/* verify error from callback */
static CURLSTScode hstsreadfail(CURL *easy, struct curl_hstsentry *e,
void *userp)
{
(void)easy;
(void)e;
(void)userp;
return CURLSTS_FAIL;
}
/* check that we get the hosts back in the save */
static CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *e,
struct curl_index *i, void *userp)
{
(void)easy;
(void)userp;
printf("[%zu/%zu] %s %s\n", i->index, i->total, e->name, e->expire);
return CURLSTS_OK;
}
/*
* Read/write HSTS cache entries via callback.
*/
int test(char *URL)
{
CURLcode ret = CURLE_OK;
CURL *hnd;
struct state st = {0};
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
if(hnd) {
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_HSTSREADFUNCTION, hstsread);
curl_easy_setopt(hnd, CURLOPT_HSTSREADDATA, &st);
curl_easy_setopt(hnd, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
curl_easy_setopt(hnd, CURLOPT_HSTSWRITEDATA, &st);
curl_easy_setopt(hnd, CURLOPT_HSTS_CTRL, CURLHSTS_ENABLE);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
printf("First request returned %d\n", (int)ret);
}
hnd = curl_easy_init();
if(hnd) {
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_HSTSREADFUNCTION, hstsreadfail);
curl_easy_setopt(hnd, CURLOPT_HSTSREADDATA, &st);
curl_easy_setopt(hnd, CURLOPT_HSTSWRITEFUNCTION, hstswrite);
curl_easy_setopt(hnd, CURLOPT_HSTSWRITEDATA, &st);
curl_easy_setopt(hnd, CURLOPT_HSTS_CTRL, CURLHSTS_ENABLE);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
printf("Second request returned %d\n", (int)ret);
}
curl_global_cleanup();
return (int)ret;
}

View file

@ -0,0 +1,56 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2020 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
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) {
curl_easy_setopt(curl, CURLOPT_URL, URL);
#ifdef LIB1917
/* without any postfields set! */
curl_easy_setopt(curl, CURLOPT_POST, 1L);
#else
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "");
#endif
res = curl_easy_perform(curl);
if(res) {
printf("res: %d\n", res);
}
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,57 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
const struct curl_easyoption *o;
int error = 0;
(void)URL;
curl_global_init(CURL_GLOBAL_ALL);
for(o = curl_easy_option_next(NULL);
o;
o = curl_easy_option_next(o)) {
const struct curl_easyoption *ename =
curl_easy_option_by_name(o->name);
const struct curl_easyoption *eid =
curl_easy_option_by_id(o->id);
if(ename->id != o->id) {
printf("name lookup id %d doesn't match %d\n",
ename->id, o->id);
}
else if(eid->id != o->id) {
printf("ID lookup %d doesn't match %d\n",
ename->id, o->id);
}
}
curl_global_cleanup();
return error;
}

View file

@ -0,0 +1,53 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
int i;
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BEARER);
curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER,
"c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca1");
curl_easy_setopt(curl, CURLOPT_SASL_AUTHZID,
"c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca2");
curl_easy_setopt(curl, CURLOPT_URL, URL);
for(i = 0; i < 2; i++)
/* the second request needs to do connection reuse */
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,62 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = 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;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "xxx");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,63 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = 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;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "xxx:yyy");
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,63 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = 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;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "xxx:yyy:rrr");
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,63 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = 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;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "xxx:yyy:rrr:sss");
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,66 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = 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;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_POST, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "provider1:provider2:region:service");
test_setopt(curl, CURLOPT_USERPWD, "keyId:SecretKey");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
test_setopt(curl, CURLOPT_POSTFIELDS, "postData");
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,68 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = NULL;
unsigned char data[] = {0x70, 0x6f, 0x73, 0x74, 0, 0x44, 0x61, 0x74, 0x61};
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;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_POST, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "provider1:provider2:region:service");
test_setopt(curl, CURLOPT_USERPWD, "keyId:SecretKey");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
test_setopt(curl, CURLOPT_POSTFIELDS, data);
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)sizeof(data));
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,72 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLM *multi;
CURL *easy;
int running_handles;
curl_global_init(CURL_GLOBAL_DEFAULT);
multi = curl_multi_init();
if(multi) {
easy = curl_easy_init();
if(easy) {
CURLcode c;
CURLMcode m;
/* Crash only happens when using HTTPS */
c = curl_easy_setopt(easy, CURLOPT_URL, URL);
if(!c)
/* Any old HTTP tunneling proxy will do here */
c = curl_easy_setopt(easy, CURLOPT_PROXY, libtest_arg2);
if(!c) {
/* We're going to drive the transfer using multi interface here,
because we want to stop during the middle. */
m = curl_multi_add_handle(multi, easy);
if(!m)
/* Run the multi handle once, just enough to start establishing an
HTTPS connection. */
m = curl_multi_perform(multi, &running_handles);
if(m)
fprintf(stderr, "curl_multi_perform failed\n");
}
/* Close the easy handle *before* the multi handle. Doing it the other
way around avoids the issue. */
curl_easy_cleanup(easy);
}
curl_multi_cleanup(multi); /* double-free happens here */
}
curl_global_cleanup();
return CURLE_OK;
}

View file

@ -0,0 +1,119 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static const char *show[]={
"daTE",
"Server",
"content-type",
"content-length",
"location",
"set-cookie",
"silly-thing",
"fold",
NULL
};
#ifdef LIB1946
#define HEADER_REQUEST 0
#else
#define HEADER_REQUEST -1
#endif
static void showem(CURL *easy, unsigned int type)
{
int i;
struct curl_header *header;
for(i = 0; show[i]; i++) {
if(CURLHE_OK == curl_easy_header(easy, show[i], 0, type, HEADER_REQUEST,
&header)) {
if(header->amount > 1) {
/* more than one, iterate over them */
size_t index = 0;
size_t amount = header->amount;
do {
printf("- %s == %s (%u/%u)\n", header->name, header->value,
(int)index, (int)amount);
if(++index == amount)
break;
if(CURLHE_OK != curl_easy_header(easy, show[i], index, type,
HEADER_REQUEST, &header))
break;
} while(1);
}
else {
/* only one of this */
printf(" %s == %s\n", header->name, header->value);
}
}
}
}
static size_t write_cb(char *data, size_t n, size_t l, void *userp)
{
/* take care of the data here, ignored in this example */
(void)data;
(void)userp;
return n*l;
}
int test(char *URL)
{
CURL *easy;
curl_global_init(CURL_GLOBAL_DEFAULT);
easy = curl_easy_init();
if(easy) {
CURLcode res;
curl_easy_setopt(easy, CURLOPT_URL, URL);
curl_easy_setopt(easy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
/* ignores any content */
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, write_cb);
/* if there's a proxy set, use it */
if(libtest_arg2 && *libtest_arg2) {
curl_easy_setopt(easy, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(easy, CURLOPT_HTTPPROXYTUNNEL, 1L);
}
res = curl_easy_perform(easy);
if(res) {
printf("badness: %d\n", (int)res);
}
showem(easy, CURLH_HEADER);
if(libtest_arg2 && *libtest_arg2) {
/* now show connect headers only */
showem(easy, CURLH_CONNECT);
}
showem(easy, CURLH_1XX);
showem(easy, CURLH_TRAILER);
curl_easy_cleanup(easy);
}
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,81 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.haxx.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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
#ifdef _MSC_VER
/* warning C4706: assignment within conditional expression */
#pragma warning(disable:4706)
#endif
static void showem(CURL *easy, unsigned int type)
{
struct curl_header *header = NULL;
struct curl_header *prev = NULL;
while((header = curl_easy_nextheader(easy, type, 0, prev))) {
printf(" %s == %s (%u/%u)\n", header->name, header->value,
(int)header->index, (int)header->amount);
prev = header;
}
}
static size_t write_cb(char *data, size_t n, size_t l, void *userp)
{
/* take care of the data here, ignored in this example */
(void)data;
(void)userp;
return n*l;
}
int test(char *URL)
{
CURL *easy;
curl_global_init(CURL_GLOBAL_DEFAULT);
easy = curl_easy_init();
if(easy) {
CURLcode res;
curl_easy_setopt(easy, CURLOPT_URL, URL);
curl_easy_setopt(easy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
/* ignores any content */
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, write_cb);
/* if there's a proxy set, use it */
if(libtest_arg2 && *libtest_arg2) {
curl_easy_setopt(easy, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(easy, CURLOPT_HTTPPROXYTUNNEL, 1L);
}
res = curl_easy_perform(easy);
if(res) {
printf("badness: %d\n", (int)res);
}
showem(easy, CURLH_CONNECT|CURLH_HEADER|CURLH_TRAILER|CURLH_1XX);
curl_easy_cleanup(easy);
}
curl_global_cleanup();
return 0;
}

View file

@ -0,0 +1,68 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2020 - 2022, Nicolas Sterchele, <nicolas@sterchelen.net>
*
* 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret = CURLE_OK;
CURL *curl = NULL;
curl_off_t retry_after;
char *follow_url = NULL;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, URL);
ret = curl_easy_perform(curl);
if(ret) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, ret, curl_easy_strerror(ret));
goto test_cleanup;
}
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &follow_url);
curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry_after);
printf("Retry-After %" CURL_FORMAT_CURL_OFF_T "\n", retry_after);
curl_easy_setopt(curl, CURLOPT_URL, follow_url);
ret = curl_easy_perform(curl);
if(ret) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, ret, curl_easy_strerror(ret));
goto test_cleanup;
}
curl_easy_reset(curl);
curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry_after);
printf("Retry-After %" CURL_FORMAT_CURL_OFF_T "\n", retry_after);
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return ret;
}

View file

@ -0,0 +1,61 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#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;
}

View file

@ -0,0 +1,163 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#define NUM_THREADS 100
#ifdef WIN32
static DWORD WINAPI run_thread(LPVOID ptr)
{
CURLcode *result = ptr;
*result = curl_global_init(CURL_GLOBAL_ALL);
if(*result == CURLE_OK)
curl_global_cleanup();
return 0;
}
int test(char *URL)
{
CURLcode results[NUM_THREADS];
HANDLE ths[NUM_THREADS];
unsigned tid_count = NUM_THREADS, i;
int test_failure = 0;
curl_version_info_data *ver;
(void) URL;
ver = curl_version_info(CURLVERSION_NOW);
if((ver->features & CURL_VERSION_THREADSAFE) == 0) {
fprintf(stderr, "%s:%d On Windows but the "
"CURL_VERSION_THREADSAFE feature flag is not set\n",
__FILE__, __LINE__);
return -1;
}
for(i = 0; i < tid_count; i++) {
HANDLE th;
results[i] = CURL_LAST; /* initialize with invalid value */
th = CreateThread(NULL, 0, run_thread, &results[i], 0, NULL);
if(!th) {
fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n",
__FILE__, __LINE__, GetLastError());
tid_count = i;
test_failure = -1;
goto cleanup;
}
ths[i] = th;
}
cleanup:
for(i = 0; i < tid_count; i++) {
WaitForSingleObject(ths[i], INFINITE);
CloseHandle(ths[i]);
if(results[i] != CURLE_OK) {
fprintf(stderr, "%s:%d thread[%u]: curl_global_init() failed,"
"with code %d (%s)\n", __FILE__, __LINE__,
i, (int) results[i], curl_easy_strerror(results[i]));
test_failure = -1;
}
}
return test_failure;
}
#elif defined(HAVE_PTHREAD_H)
#include <pthread.h>
#include <unistd.h>
static void *run_thread(void *ptr)
{
CURLcode *result = ptr;
*result = curl_global_init(CURL_GLOBAL_ALL);
if(*result == CURLE_OK)
curl_global_cleanup();
return NULL;
}
int test(char *URL)
{
CURLcode results[NUM_THREADS];
pthread_t tids[NUM_THREADS];
unsigned tid_count = NUM_THREADS, i;
int test_failure = 0;
curl_version_info_data *ver;
(void) URL;
ver = curl_version_info(CURLVERSION_NOW);
if((ver->features & CURL_VERSION_THREADSAFE) == 0) {
fprintf(stderr, "%s:%d Have pthread but the "
"CURL_VERSION_THREADSAFE feature flag is not set\n",
__FILE__, __LINE__);
return -1;
}
for(i = 0; i < tid_count; i++) {
int res;
results[i] = CURL_LAST; /* initialize with invalid value */
res = pthread_create(&tids[i], NULL, run_thread, &results[i]);
if(res) {
fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n",
__FILE__, __LINE__, res);
tid_count = i;
test_failure = -1;
goto cleanup;
}
}
cleanup:
for(i = 0; i < tid_count; i++) {
pthread_join(tids[i], NULL);
if(results[i] != CURLE_OK) {
fprintf(stderr, "%s:%d thread[%u]: curl_global_init() failed,"
"with code %d (%s)\n", __FILE__, __LINE__,
i, (int) results[i], curl_easy_strerror(results[i]));
test_failure = -1;
}
}
return test_failure;
}
#else /* without pthread or Windows, this test doesn't work */
int test(char *URL)
{
curl_version_info_data *ver;
(void)URL;
ver = curl_version_info(CURLVERSION_NOW);
if((ver->features & CURL_VERSION_THREADSAFE) != 0) {
fprintf(stderr, "%s:%d No pthread but the "
"CURL_VERSION_THREADSAFE feature flag is set\n",
__FILE__, __LINE__);
return -1;
}
return 0;
}
#endif

View file

@ -0,0 +1,158 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
#include "memdebug.h"
#ifdef LIB585
static int counter;
static curl_socket_t tst_opensocket(void *clientp,
curlsocktype purpose,
struct curl_sockaddr *addr)
{
(void)clientp;
(void)purpose;
printf("[OPEN] counter: %d\n", ++counter);
return socket(addr->family, addr->socktype, addr->protocol);
}
static int tst_closesocket(void *clientp, curl_socket_t sock)
{
(void)clientp;
printf("[CLOSE] counter: %d\n", counter--);
return sclose(sock);
}
static void setupcallbacks(CURL *curl)
{
curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, tst_opensocket);
curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, tst_closesocket);
counter = 0;
}
#else
#define setupcallbacks(x) Curl_nop_stmt
#endif
int test(char *URL)
{
CURLcode res;
CURL *curl;
char *ipstr = 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;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 1;
test_setopt(curl, CURLOPT_DEBUGDATA, &libtest_debug_config);
test_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp"))
test_setopt(curl, CURLOPT_FTPPORT, "-");
setupcallbacks(curl);
res = curl_easy_perform(curl);
if(!res) {
res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr);
if(libtest_arg2) {
FILE *moo = fopen(libtest_arg2, "wb");
if(moo) {
curl_off_t time_namelookup;
curl_off_t time_connect;
curl_off_t time_pretransfer;
curl_off_t time_starttransfer;
curl_off_t time_total;
fprintf(moo, "IP %s\n", ipstr);
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T, &time_namelookup);
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &time_connect);
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T,
&time_pretransfer);
curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME_T,
&time_starttransfer);
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &time_total);
/* since the timing will always vary we only compare relative
differences between these 5 times */
if(time_namelookup > time_connect) {
fprintf(moo, "namelookup vs connect: %" CURL_FORMAT_CURL_OFF_T
".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
(time_namelookup / 1000000),
(long)(time_namelookup % 1000000),
(time_connect / 1000000), (long)(time_connect % 1000000));
}
if(time_connect > time_pretransfer) {
fprintf(moo, "connect vs pretransfer: %" CURL_FORMAT_CURL_OFF_T
".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
(time_connect / 1000000), (long)(time_connect % 1000000),
(time_pretransfer / 1000000),
(long)(time_pretransfer % 1000000));
}
if(time_pretransfer > time_starttransfer) {
fprintf(moo, "pretransfer vs starttransfer: %" CURL_FORMAT_CURL_OFF_T
".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
(time_pretransfer / 1000000),
(long)(time_pretransfer % 1000000),
(time_starttransfer / 1000000),
(long)(time_starttransfer % 1000000));
}
if(time_starttransfer > time_total) {
fprintf(moo, "starttransfer vs total: %" CURL_FORMAT_CURL_OFF_T
".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
(time_starttransfer / 1000000),
(long)(time_starttransfer % 1000000),
(time_total / 1000000), (long)(time_total % 1000000));
}
fclose(moo);
}
}
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,60 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
(void)URL; /* we don't use this */
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;
}
test_setopt(curl, CURLOPT_HEADER, 1L);
/* just verify that setting this to -1 is fine */
test_setopt(curl, CURLOPT_MAXREDIRS, -1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,93 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Get a single URL without select().
*/
int test(char *URL)
{
CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
int running;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
easy_setopt(c, CURLOPT_URL, URL);
multi_init(m);
multi_add_handle(m, c);
for(;;) {
struct timeval timeout;
fd_set fdread, fdwrite, fdexcep;
int maxfd = -99;
timeout.tv_sec = 0;
timeout.tv_usec = 100000L; /* 100 ms */
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,103 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Source code in here hugely as reported in bug report 651460 by
* Christopher R. Palmer.
*
* Use multi interface to get HTTPS document over proxy, and provide
* auth info.
*/
int test(char *URL)
{
CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
int running;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
easy_setopt(c, CURLOPT_URL, URL);
easy_setopt(c, CURLOPT_USERPWD, "test:ing");
easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
easy_setopt(c, CURLOPT_HEADER, 1L);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
multi_init(m);
multi_add_handle(m, c);
for(;;) {
struct timeval interval;
fd_set rd, wr, exc;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,115 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Source code in here hugely as reported in bug report 651464 by
* Christopher R. Palmer.
*
* Use multi interface to get document over proxy with bad port number.
* This caused the interface to "hang" in libcurl 7.10.2.
*/
int test(char *URL)
{
CURL *c = NULL;
int res = 0;
CURLM *m = NULL;
fd_set rd, wr, exc;
int running;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
easy_init(c);
/* The point here is that there must not be anything running on the given
proxy port */
if(libtest_arg2)
easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
easy_setopt(c, CURLOPT_URL, URL);
easy_setopt(c, CURLOPT_VERBOSE, 1L);
multi_init(m);
multi_add_handle(m, c);
for(;;) {
struct timeval interval;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
fprintf(stderr, "curl_multi_perform()\n");
multi_perform(m, &running);
abort_on_test_timeout();
if(!running) {
/* This is where this code is expected to reach */
int numleft;
CURLMsg *msg = curl_multi_info_read(m, &numleft);
fprintf(stderr, "Expected: not running\n");
if(msg && !numleft)
res = TEST_ERR_SUCCESS; /* this is where we should be */
else
res = TEST_ERR_FAILURE; /* not correct */
break; /* done */
}
fprintf(stderr, "running == %d\n", running);
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
fprintf(stderr, "curl_multi_fdset()\n");
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PA */
curl_multi_remove_handle(m, c);
curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,152 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include "memdebug.h"
/*
* This example shows an FTP upload, with a rename of the file just after
* a successful upload.
*
* Example based on source code provided by Erick Nuwendam. Thanks!
*/
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
FILE *hd_src;
int hd;
struct_stat file_info;
struct curl_slist *hl;
struct curl_slist *headerlist = NULL;
const char *buf_1 = "RNFR 505";
const char *buf_2 = "RNTO 505-forreal";
if(!libtest_arg2) {
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
return TEST_ERR_USAGE;
}
hd_src = fopen(libtest_arg2, "rb");
if(!hd_src) {
fprintf(stderr, "fopen failed with error: %d %s\n",
errno, strerror(errno));
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */
}
/* get the file size of the local file */
hd = fstat(fileno(hd_src), &file_info);
if(hd == -1) {
/* can't open file, bail out */
fprintf(stderr, "fstat() failed with error: %d %s\n",
errno, strerror(errno));
fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
if(!file_info.st_size) {
fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2);
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
/* get a curl handle */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
/* build a list of commands to pass to libcurl */
hl = curl_slist_append(headerlist, buf_1);
if(!hl) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
headerlist = curl_slist_append(hl, buf_2);
if(!headerlist) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_slist_free_all(hl);
curl_easy_cleanup(curl);
curl_global_cleanup();
fclose(hd_src);
return TEST_ERR_MAJOR_BAD;
}
headerlist = hl;
/* enable uploading */
test_setopt(curl, CURLOPT_UPLOAD, 1L);
/* enable verbose */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */
test_setopt(curl, CURLOPT_URL, URL);
/* pass in that last of FTP commands to run after the transfer */
test_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
/* now specify which file to upload */
test_setopt(curl, CURLOPT_READDATA, hd_src);
/* and give the size of the upload (optional) */
test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
test_cleanup:
/* clean up the FTP commands list */
curl_slist_free_all(headerlist);
/* close the local file */
fclose(hd_src);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,382 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static const char *HOSTHEADER = "Host: www.host.foo.com";
static const char *JAR = "log/jar506";
#define THREADS 2
/* struct containing data of a thread */
struct Tdata {
CURLSH *share;
char *url;
};
struct userdata {
const char *text;
int counter;
};
static int locks[3];
/* lock callback */
static void my_lock(CURL *handle, curl_lock_data data,
curl_lock_access laccess, void *useptr)
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
int locknum;
(void)handle;
(void)laccess;
switch(data) {
case CURL_LOCK_DATA_SHARE:
what = "share";
locknum = 0;
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
locknum = 1;
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
locknum = 2;
break;
default:
fprintf(stderr, "lock: no such data: %d\n", (int)data);
return;
}
/* detect locking of locked locks */
if(locks[locknum]) {
printf("lock: double locked %s\n", what);
return;
}
locks[locknum]++;
printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* unlock callback */
static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
int locknum;
(void)handle;
switch(data) {
case CURL_LOCK_DATA_SHARE:
what = "share";
locknum = 0;
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
locknum = 1;
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
locknum = 2;
break;
default:
fprintf(stderr, "unlock: no such data: %d\n", (int)data);
return;
}
/* detect unlocking of unlocked locks */
if(!locks[locknum]) {
printf("unlock: double unlocked %s\n", what);
return;
}
locks[locknum]--;
printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* build host entry */
static struct curl_slist *sethost(struct curl_slist *headers)
{
(void)headers;
return curl_slist_append(NULL, HOSTHEADER);
}
/* the dummy thread function */
static void *fire(void *ptr)
{
CURLcode code;
struct curl_slist *headers;
struct Tdata *tdata = (struct Tdata*)ptr;
CURL *curl;
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
return NULL;
}
headers = sethost(NULL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
printf("CURLOPT_SHARE\n");
curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
printf("PERFORM\n");
code = curl_easy_perform(curl);
if(code) {
int i = 0;
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
tdata->url, i, (int)code);
}
printf("CLEANUP\n");
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
return NULL;
}
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
/* test function */
int test(char *URL)
{
int res;
CURLSHcode scode = CURLSHE_OK;
CURLcode code = CURLE_OK;
char *url = NULL;
struct Tdata tdata;
CURL *curl;
CURLSH *share;
struct curl_slist *headers = NULL;
struct curl_slist *cookies = NULL;
struct curl_slist *next_cookie = NULL;
int i;
struct userdata user;
user.text = "Pigs in space";
user.counter = 0;
printf("GLOBAL_INIT\n");
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* prepare share */
printf("SHARE_INIT\n");
share = curl_share_init();
if(!share) {
fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_LOCKFUNC\n");
scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_UNLOCKFUNC\n");
scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_USERDATA\n");
scode = curl_share_setopt(share, CURLSHOPT_USERDATA, &user);
}
if(CURLSHE_OK == scode) {
printf("CURL_LOCK_DATA_COOKIE\n");
scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
}
if(CURLSHE_OK == scode) {
printf("CURL_LOCK_DATA_DNS\n");
scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
}
if(CURLSHE_OK != scode) {
fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* initial cookie manipulation */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
printf("CURLOPT_SHARE\n");
test_setopt(curl, CURLOPT_SHARE, share);
printf("CURLOPT_COOKIELIST injected_and_clobbered\n");
test_setopt(curl, CURLOPT_COOKIELIST,
"Set-Cookie: injected_and_clobbered=yes; "
"domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030");
printf("CURLOPT_COOKIELIST ALL\n");
test_setopt(curl, CURLOPT_COOKIELIST, "ALL");
printf("CURLOPT_COOKIELIST session\n");
test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants");
printf("CURLOPT_COOKIELIST injected\n");
test_setopt(curl, CURLOPT_COOKIELIST,
"Set-Cookie: injected=yes; domain=host.foo.com; "
"expires=Sat Feb 2 11:56:27 GMT 2030");
printf("CURLOPT_COOKIELIST SESS\n");
test_setopt(curl, CURLOPT_COOKIELIST, "SESS");
printf("CLEANUP\n");
curl_easy_cleanup(curl);
res = 0;
/* start treads */
for(i = 1; i <= THREADS; i++) {
/* set thread data */
tdata.url = suburl(URL, i); /* must be curl_free()d */
tdata.share = share;
/* simulate thread, direct call of "thread" function */
printf("*** run %d\n",i);
fire(&tdata);
curl_free(tdata.url);
}
/* fetch a another one and save cookies */
printf("*** run %d\n", i);
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = suburl(URL, i);
headers = sethost(NULL);
test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt(curl, CURLOPT_URL, url);
printf("CURLOPT_SHARE\n");
test_setopt(curl, CURLOPT_SHARE, share);
printf("CURLOPT_COOKIEJAR\n");
test_setopt(curl, CURLOPT_COOKIEJAR, JAR);
printf("CURLOPT_COOKIELIST FLUSH\n");
test_setopt(curl, CURLOPT_COOKIELIST, "FLUSH");
printf("PERFORM\n");
curl_easy_perform(curl);
printf("CLEANUP\n");
curl_easy_cleanup(curl);
curl_free(url);
curl_slist_free_all(headers);
/* load cookies */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = suburl(URL, i);
headers = sethost(NULL);
test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt(curl, CURLOPT_URL, url);
printf("CURLOPT_SHARE\n");
test_setopt(curl, CURLOPT_SHARE, share);
printf("CURLOPT_COOKIELIST ALL\n");
test_setopt(curl, CURLOPT_COOKIELIST, "ALL");
printf("CURLOPT_COOKIEJAR\n");
test_setopt(curl, CURLOPT_COOKIEFILE, JAR);
printf("CURLOPT_COOKIELIST RELOAD\n");
test_setopt(curl, CURLOPT_COOKIELIST, "RELOAD");
code = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if(code != CURLE_OK) {
fprintf(stderr, "curl_easy_getinfo() failed\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
printf("loaded cookies:\n");
if(!cookies) {
fprintf(stderr, " reloading cookies from '%s' failed\n", JAR);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
printf("-----------------\n");
next_cookie = cookies;
while(next_cookie) {
printf(" %s\n", next_cookie->data);
next_cookie = next_cookie->next;
}
printf("-----------------\n");
curl_slist_free_all(cookies);
/* try to free share, expect to fail because share is in use*/
printf("try SHARE_CLEANUP...\n");
scode = curl_share_cleanup(share);
if(scode == CURLSHE_OK) {
fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL;
}
else {
printf("SHARE_CLEANUP failed, correct\n");
}
test_cleanup:
/* clean up last handle */
printf("CLEANUP\n");
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
curl_free(url);
/* free share */
printf("SHARE_CLEANUP\n");
scode = curl_share_cleanup(share);
if(scode != CURLSHE_OK)
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode);
printf("GLOBAL_CLEANUP\n");
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,102 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *curls = NULL;
CURLM *multi = NULL;
int still_running;
int i = -1;
int res = 0;
CURLMsg *msg;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}

View file

@ -0,0 +1,105 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static char data[]="this is what we post to the silly web server\n";
struct WriteThis {
char *readptr;
size_t sizeleft;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct WriteThis *pooh = (struct WriteThis *)userp;
if(size*nmemb < 1)
return 0;
if(pooh->sizeleft) {
*ptr = pooh->readptr[0]; /* copy one single byte */
pooh->readptr++; /* advance pointer */
pooh->sizeleft--; /* less data left */
return 1; /* we return 1 byte at a time! */
}
return 0; /* no more data left to deliver */
}
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
struct WriteThis pooh;
pooh.readptr = data;
pooh.sizeleft = strlen(data);
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;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,117 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include <string.h>
/*
* This test uses these funny custom memory callbacks for the only purpose
* of verifying that curl_global_init_mem() functionality is present in
* libcurl and that it works unconditionally no matter how libcurl is built,
* nothing more.
*
* Do not include memdebug.h in this source file, and do not use directly
* memory related functions in this file except those used inside custom
* memory callbacks which should be calling 'the real thing'.
*/
static int seen;
static void *custom_calloc(size_t nmemb, size_t size)
{
seen++;
return (calloc)(nmemb, size);
}
static void *custom_malloc(size_t size)
{
seen++;
return (malloc)(size);
}
static char *custom_strdup(const char *ptr)
{
seen++;
return (strdup)(ptr);
}
static void *custom_realloc(void *ptr, size_t size)
{
seen++;
return (realloc)(ptr, size);
}
static void custom_free(void *ptr)
{
seen++;
(free)(ptr);
}
int test(char *URL)
{
unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7};
CURLcode res;
CURL *curl;
int asize;
char *str = NULL;
(void)URL;
res = curl_global_init_mem(CURL_GLOBAL_ALL,
custom_malloc,
custom_free,
custom_realloc,
custom_strdup,
custom_calloc);
if(res != CURLE_OK) {
fprintf(stderr, "curl_global_init_mem() 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;
}
test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses strdup() */
asize = (int)sizeof(a);
str = curl_easy_escape(curl, (char *)a, asize); /* uses realloc() */
if(seen)
printf("Callbacks were invoked!\n");
test_cleanup:
if(str)
curl_free(str);
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

View file

@ -0,0 +1,132 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static const char *post[]={
"one",
"two",
"three",
"and a final longer crap: four",
NULL
};
struct WriteThis {
int counter;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct WriteThis *pooh = (struct WriteThis *)userp;
const char *data;
if(size*nmemb < 1)
return 0;
data = post[pooh->counter];
if(data) {
size_t len = strlen(data);
if(size*nmemb < len) {
fprintf(stderr, "read buffer is too small to run test\n");
return 0;
}
memcpy(ptr, data, len);
pooh->counter++; /* advance pointer */
return len;
}
return 0; /* no more data left to deliver */
}
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
struct curl_slist *slist = NULL;
struct WriteThis pooh;
pooh.counter = 0;
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;
}
slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
if(!slist) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* enforce chunked transfer by setting the header */
test_setopt(curl, CURLOPT_HTTPHEADER, slist);
#ifdef LIB565
test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
test_setopt(curl, CURLOPT_USERPWD, "foo:bar");
#endif
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* clean up the headers list */
if(slist)
curl_slist_free_all(slist);
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}

View file

@ -0,0 +1,58 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2022, 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.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
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;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_FILETIME, 1L);
test_setopt(curl, CURLOPT_NOBODY, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}

Some files were not shown because too many files have changed in this diff Show more