Add project files.
This commit is contained in:
126
3rd-party/curl-7.52.1/tests/libtest/CMakeLists.txt
vendored
Normal file
126
3rd-party/curl-7.52.1/tests/libtest/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
set(TARGET_LABEL_PREFIX "Test ")
|
||||
|
||||
function(SETUP_TEST TEST_NAME) # ARGN are the files in the test
|
||||
add_executable( ${TEST_NAME} ${ARGN} )
|
||||
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/curlbuild.h"
|
||||
)
|
||||
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}")
|
||||
|
||||
# Add the postfix to the executable since it is
|
||||
# not added automatically as for modules and shared libraries
|
||||
set_target_properties(${TEST_NAME}
|
||||
PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
|
||||
|
||||
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})
|
||||
setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES})
|
||||
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 sethostname.c sethostname.h)
|
||||
# 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()
|
||||
|
||||
# # files used only in some libcurl test programs
|
||||
# SET(TESTUTIL testutil.c testutil.h)
|
||||
|
||||
# # these files are used in every single test program below
|
||||
# SET(SUPPORTFILES first.c test.h)
|
||||
|
||||
# # These are all libcurl test programs
|
||||
# SET(noinst_PROGRAMS
|
||||
# lib500 lib501 lib502 lib503 lib504 lib505 lib506
|
||||
# lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516
|
||||
# lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526
|
||||
# #lib527
|
||||
# #lib529
|
||||
# lib530
|
||||
# #lib532
|
||||
# lib533 lib536 lib537 lib540 lib541 lib542 lib543
|
||||
# lib544
|
||||
# #lib545
|
||||
# lib547
|
||||
# #lib548
|
||||
# lib549 lib552 lib553 lib554 lib555 lib556
|
||||
# lib539 lib557
|
||||
# lib560
|
||||
# )
|
||||
|
||||
# SET(noinst_PROGRAMS_USE_TESTUTIL
|
||||
# lib502 lib503 lib504
|
||||
# lib507
|
||||
# lib525 lib526 lib527
|
||||
# lib529
|
||||
# lib530
|
||||
# lib532
|
||||
# lib533 lib536
|
||||
# lib555
|
||||
# )
|
||||
|
||||
# MACRO(ADD_TESTUTIL_IF_NECESSARY TEST_NAME)
|
||||
# LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL)
|
||||
# IF(NOT ${USES_TESTUTIL} EQUAL -1)
|
||||
# LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil
|
||||
# ENDIF()
|
||||
# ENDMACRO()
|
||||
|
||||
# # General case
|
||||
# FOREACH(TEST_NAME ${noinst_PROGRAMS})
|
||||
# SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES})
|
||||
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
|
||||
# SETUP_TEST(${TEST_NAME} ${SOURCE})
|
||||
# ENDFOREACH()
|
||||
|
||||
# # Special cases
|
||||
# SET(TEST_NAME lib527)
|
||||
# SET(SOURCE "lib526.c" ${SUPPORTFILES})
|
||||
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
|
||||
# SETUP_TEST(${TEST_NAME} ${SOURCE})
|
||||
|
||||
# SET(TEST_NAME lib529)
|
||||
# SET(SOURCE "lib525.c" ${SUPPORTFILES})
|
||||
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
|
||||
# SETUP_TEST(${TEST_NAME} ${SOURCE})
|
||||
|
||||
# SET(TEST_NAME lib532)
|
||||
# SET(SOURCE "lib526.c" ${SUPPORTFILES})
|
||||
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
|
||||
# SETUP_TEST(${TEST_NAME} ${SOURCE})
|
||||
|
||||
# SET(TEST_NAME lib545)
|
||||
# SET(SOURCE "lib544.c" ${SUPPORTFILES})
|
||||
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
|
||||
# SETUP_TEST(${TEST_NAME} ${SOURCE})
|
||||
|
||||
# SET(TEST_NAME lib548)
|
||||
# SET(SOURCE "lib547.c" ${SUPPORTFILES})
|
||||
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
|
||||
# SETUP_TEST(${TEST_NAME} ${SOURCE})
|
120
3rd-party/curl-7.52.1/tests/libtest/Makefile.am
vendored
Normal file
120
3rd-party/curl-7.52.1/tests/libtest/Makefile.am
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2016, 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.
|
||||
#
|
||||
###########################################################################
|
||||
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_builddir)/include/curl for generated curlbuild.h included from curl.h
|
||||
# $(top_builddir)/include for generated curlbuild.h inc. from lib/curl_setup.h
|
||||
# $(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
|
||||
# $(top_builddir)/ares is for in-tree c-ares's generated ares_build.h file
|
||||
# $(top_srcdir)/ares is for in-tree c-ares's external include files
|
||||
|
||||
if USE_EMBEDDED_ARES
|
||||
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(top_srcdir)/lib \
|
||||
-I$(top_builddir)/ares \
|
||||
-I$(top_srcdir)/ares
|
||||
else
|
||||
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/lib \
|
||||
-I$(top_srcdir)/lib
|
||||
endif
|
||||
|
||||
EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \
|
||||
test1022.pl Makefile.inc notexists.pl CMakeLists.txt
|
||||
|
||||
CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@
|
||||
|
||||
# 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 overriden)
|
||||
LDADD = $(SUPPORTFILES_LIBS)
|
||||
DEPENDENCIES = $(top_builddir)/lib/libcurl.la
|
||||
|
||||
# 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 =
|
||||
|
||||
if CURL_LT_SHLIB_USE_NO_UNDEFINED
|
||||
libhostname_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 =
|
||||
|
||||
checksrc:
|
||||
@PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c
|
7499
3rd-party/curl-7.52.1/tests/libtest/Makefile.in
vendored
Normal file
7499
3rd-party/curl-7.52.1/tests/libtest/Makefile.in
vendored
Normal file
File diff suppressed because it is too large
Load Diff
421
3rd-party/curl-7.52.1/tests/libtest/Makefile.inc
vendored
Normal file
421
3rd-party/curl-7.52.1/tests/libtest/Makefile.inc
vendored
Normal file
@@ -0,0 +1,421 @@
|
||||
# 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
|
||||
|
||||
# these files are used in every single test program below
|
||||
SUPPORTFILES = first.c test.h
|
||||
|
||||
# These are all libcurl test programs
|
||||
noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
|
||||
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 lib536 lib537 lib539 lib540 lib541 lib542 lib543 lib544 lib545 \
|
||||
lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 lib557 lib558 \
|
||||
lib560 lib562 lib564 lib565 lib566 lib567 lib568 lib569 lib570 \
|
||||
lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \
|
||||
lib583 lib585 lib586 lib587 lib590 lib591 lib597 lib598 lib599 \
|
||||
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
|
||||
lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \
|
||||
lib1520 \
|
||||
lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \
|
||||
lib1534 lib1535 lib1536 \
|
||||
lib1900 \
|
||||
lib2033
|
||||
|
||||
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)
|
||||
|
||||
lib500_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
lib529_LDADD = $(TESTUTIL_LIBS)
|
||||
lib529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB529
|
||||
|
||||
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib530_LDADD = $(TESTUTIL_LIBS)
|
||||
lib530_CPPFLAGS = $(AM_CPPFLAGS) -DLIB530
|
||||
|
||||
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)
|
||||
|
||||
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib536_LDADD = $(TESTUTIL_LIBS)
|
||||
lib536_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS)
|
||||
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)
|
||||
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)
|
||||
|
||||
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)
|
||||
lib566_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib567_SOURCES = lib567.c $(SUPPORTFILES)
|
||||
lib567_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib568_SOURCES = lib568.c $(SUPPORTFILES)
|
||||
lib568_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib569_SOURCES = lib569.c $(SUPPORTFILES)
|
||||
lib569_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib570_SOURCES = lib570.c $(SUPPORTFILES)
|
||||
lib570_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS)
|
||||
lib571_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib572_SOURCES = lib572.c $(SUPPORTFILES)
|
||||
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)
|
||||
lib578_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib579_SOURCES = lib579.c $(SUPPORTFILES)
|
||||
lib579_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib582_LDADD = $(TESTUTIL_LIBS)
|
||||
lib582_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib583_SOURCES = lib583.c $(SUPPORTFILES)
|
||||
lib583_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib585_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE)
|
||||
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
|
||||
|
||||
lib590_SOURCES = lib590.c $(SUPPORTFILES)
|
||||
lib590_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
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)
|
||||
lib599_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
|
||||
|
||||
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
|
||||
|
||||
lib1520_SOURCES = lib1520.c $(SUPPORTFILES)
|
||||
lib1520_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1520
|
||||
|
||||
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
|
||||
|
||||
lib1900_SOURCES = lib1900.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib1900_LDADD = $(TESTUTIL_LIBS)
|
||||
lib1900_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib2033_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib2033_LDADD = $(TESTUTIL_LIBS)
|
||||
lib2033_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PIPELINING
|
47
3rd-party/curl-7.52.1/tests/libtest/chkhostname.c
vendored
Normal file
47
3rd-party/curl-7.52.1/tests/libtest/chkhostname.c
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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;
|
||||
}
|
183
3rd-party/curl-7.52.1/tests/libtest/first.c
vendored
Normal file
183
3rd-party/curl-7.52.1/tests/libtest/first.c
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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
|
||||
|
||||
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((1000*tv->tv_sec) + (DWORD)(((double)tv->tv_usec)/1000.0));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return select(nfds, rd, wr, exc, tv);
|
||||
}
|
||||
|
||||
void wait_ms(int ms)
|
||||
{
|
||||
struct timeval t;
|
||||
t.tv_sec = ms/1000;
|
||||
ms -= (int)t.tv_sec * 1000;
|
||||
t.tv_usec = ms * 1000;
|
||||
select_wrapper(0, NULL, NULL, NULL, &t);
|
||||
}
|
||||
|
||||
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_memdebug(fname);
|
||||
/* this weird stuff here is to make curl_free() get called
|
||||
before curl_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_memlimit(num);
|
||||
curl_free(env);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define memory_tracking_init() Curl_nop_stmt
|
||||
#endif
|
||||
|
||||
/* returns a hexdump in a static memory area */
|
||||
char *hexdump(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)
|
||||
snprintf(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 behaviour 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
|
||||
|
||||
return result;
|
||||
}
|
90
3rd-party/curl-7.52.1/tests/libtest/lib1500.c
vendored
Normal file
90
3rd-party/curl-7.52.1/tests/libtest/lib1500.c
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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 */
|
||||
}
|
126
3rd-party/curl-7.52.1/tests/libtest/lib1501.c
vendored
Normal file
126
3rd-party/curl-7.52.1/tests/libtest/lib1501.c
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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_US 500000
|
||||
|
||||
/* return the number of microseconds between two time stamps */
|
||||
static int elapsed(struct timeval *before,
|
||||
struct timeval *after)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
result = (after->tv_sec - before->tv_sec) * 1000000 +
|
||||
after->tv_usec - before->tv_usec;
|
||||
if(result < 0)
|
||||
result = 0;
|
||||
|
||||
return curlx_sztosi(result);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
int 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 = elapsed(&before, &after);
|
||||
fprintf(stderr, "pong = %d\n", e);
|
||||
|
||||
if(e > MAX_BLOCKED_TIME_US) {
|
||||
res = 100;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* undocumented cleanup sequence - type UA */
|
||||
|
||||
curl_multi_cleanup(mhandle);
|
||||
curl_easy_cleanup(handle);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
146
3rd-party/curl-7.52.1/tests/libtest/lib1502.c
vendored
Normal file
146
3rd-party/curl-7.52.1/tests/libtest/lib1502.c
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
* 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"
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *easy = NULL;
|
||||
CURLM *multi = NULL;
|
||||
int still_running;
|
||||
int res = 0;
|
||||
|
||||
char redirect[160];
|
||||
|
||||
/* DNS cache injection */
|
||||
struct curl_slist *dns_cache_list;
|
||||
|
||||
snprintf(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");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
res_global_init(CURL_GLOBAL_ALL);
|
||||
if(res) {
|
||||
curl_slist_free_all(dns_cache_list);
|
||||
return res;
|
||||
}
|
||||
|
||||
easy_init(easy);
|
||||
|
||||
easy_setopt(easy, CURLOPT_URL, URL);
|
||||
easy_setopt(easy, CURLOPT_HEADER, 1L);
|
||||
easy_setopt(easy, CURLOPT_RESOLVE, dns_cache_list);
|
||||
|
||||
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;
|
||||
}
|
137
3rd-party/curl-7.52.1/tests/libtest/lib1506.c
vendored
Normal file
137
3rd-party/curl-7.52.1/tests/libtest/lib1506.c
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2013, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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++) {
|
||||
snprintf(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 */
|
||||
snprintf(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;
|
||||
}
|
168
3rd-party/curl-7.52.1/tests/libtest/lib1507.c
vendored
Normal file
168
3rd-party/curl-7.52.1/tests/libtest/lib1507.c
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "testutil.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(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
(void)ptr;
|
||||
(void)size;
|
||||
(void)nmemb;
|
||||
(void)userp;
|
||||
return CURL_READFUNC_ABORT;
|
||||
}
|
||||
|
||||
static struct timeval tvnow(void)
|
||||
{
|
||||
/*
|
||||
** time() returns the value of time in seconds since the Epoch.
|
||||
*/
|
||||
struct timeval now;
|
||||
now.tv_sec = (long)time(NULL);
|
||||
now.tv_usec = 0;
|
||||
return now;
|
||||
}
|
||||
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec-older.tv_sec)*1000+
|
||||
(newer.tv_usec-older.tv_usec)/1000;
|
||||
}
|
||||
|
||||
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 = 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) {
|
||||
timeout.tv_sec = curl_timeo / 1000;
|
||||
if(timeout.tv_sec > 1)
|
||||
timeout.tv_sec = 1;
|
||||
else
|
||||
timeout.tv_usec = (curl_timeo % 1000) * 1000;
|
||||
}
|
||||
|
||||
/* 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(tvdiff(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;
|
||||
}
|
||||
|
||||
|
49
3rd-party/curl-7.52.1/tests/libtest/lib1508.c
vendored
Normal file
49
3rd-party/curl-7.52.1/tests/libtest/lib1508.c
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2013, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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;
|
||||
}
|
97
3rd-party/curl-7.52.1/tests/libtest/lib1509.c
vendored
Normal file
97
3rd-party/curl-7.52.1/tests/libtest/lib1509.c
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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);
|
||||
|
||||
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 ........: %lu\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;
|
||||
}
|
99
3rd-party/curl-7.52.1/tests/libtest/lib1510.c
vendored
Normal file
99
3rd-party/curl-7.52.1/tests/libtest/lib1510.c
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2013, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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++) {
|
||||
snprintf(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 */
|
||||
snprintf(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;
|
||||
}
|
75
3rd-party/curl-7.52.1/tests/libtest/lib1511.c
vendored
Normal file
75
3rd-party/curl-7.52.1/tests/libtest/lib1511.c
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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 != 0L) {
|
||||
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;
|
||||
}
|
91
3rd-party/curl-7.52.1/tests/libtest/lib1512.c
vendored
Normal file
91
3rd-party/curl-7.52.1/tests/libtest/lib1512.c
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2013 - 2016, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
snprintf(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 */
|
||||
snprintf(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;
|
||||
}
|
||||
|
74
3rd-party/curl-7.52.1/tests/libtest/lib1513.c
vendored
Normal file
74
3rd-party/curl-7.52.1/tests/libtest/lib1513.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
* 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;
|
||||
}
|
80
3rd-party/curl-7.52.1/tests/libtest/lib1514.c
vendored
Normal file
80
3rd-party/curl-7.52.1/tests/libtest/lib1514.c
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
* 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(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
struct WriteThis *pooh = (struct WriteThis *)userp;
|
||||
|
||||
if(size*nmemb < 1)
|
||||
return 0;
|
||||
|
||||
if(pooh->sizeleft) {
|
||||
*(char *)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);
|
||||
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)result;
|
||||
}
|
152
3rd-party/curl-7.52.1/tests/libtest/lib1515.c
vendored
Normal file
152
3rd-party/curl-7.52.1/tests/libtest/lib1515.c
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* 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(s) Sleep(s * 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();
|
||||
}
|
||||
|
||||
while((msg = curl_multi_info_read(m, &msgs_left))) {
|
||||
if(msg->msg == CURLMSG_DONE && msg->easy_handle == curls) {
|
||||
res = msg->data.result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
snprintf(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];
|
||||
snprintf(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);
|
||||
|
||||
return (int) res;
|
||||
}
|
116
3rd-party/curl-7.52.1/tests/libtest/lib1517.c
vendored
Normal file
116
3rd-party/curl-7.52.1/tests/libtest/lib1517.c
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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(void *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);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
}
|
115
3rd-party/curl-7.52.1/tests/libtest/lib1520.c
vendored
Normal file
115
3rd-party/curl-7.52.1/tests/libtest/lib1520.c
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2014, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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(void *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;
|
||||
}
|
||||
|
||||
|
98
3rd-party/curl-7.52.1/tests/libtest/lib1525.c
vendored
Normal file
98
3rd-party/curl-7.52.1/tests/libtest/lib1525.c
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2014, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* 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(void *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, strlen(data));
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
curl_slist_free_all(hhl);
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
104
3rd-party/curl-7.52.1/tests/libtest/lib1526.c
vendored
Normal file
104
3rd-party/curl-7.52.1/tests/libtest/lib1526.c
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* 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(void *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, 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;
|
||||
}
|
||||
|
100
3rd-party/curl-7.52.1/tests/libtest/lib1527.c
vendored
Normal file
100
3rd-party/curl-7.52.1/tests/libtest/lib1527.c
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* 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(void *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, 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;
|
||||
}
|
73
3rd-party/curl-7.52.1/tests/libtest/lib1528.c
vendored
Normal file
73
3rd-party/curl-7.52.1/tests/libtest/lib1528.c
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
60
3rd-party/curl-7.52.1/tests/libtest/lib1529.c
vendored
Normal file
60
3rd-party/curl-7.52.1/tests/libtest/lib1529.c
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl = NULL;
|
||||
CURLcode res = CURLE_FAILED_INIT;
|
||||
char bURL[512];
|
||||
snprintf(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;
|
||||
}
|
68
3rd-party/curl-7.52.1/tests/libtest/lib1530.c
vendored
Normal file
68
3rd-party/curl-7.52.1/tests/libtest/lib1530.c
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
144
3rd-party/curl-7.52.1/tests/libtest/lib1531.c
vendored
Normal file
144
3rd-party/curl-7.52.1/tests/libtest/lib1531.c
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
char const testData[] = ".abc\0xyz";
|
||||
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 */
|
||||
|
||||
/* 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);
|
||||
|
||||
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) {
|
||||
timeout.tv_sec = curl_timeo / 1000;
|
||||
if(timeout.tv_sec > 1)
|
||||
timeout.tv_sec = 1;
|
||||
else
|
||||
timeout.tv_usec = (curl_timeo % 1000) * 1000;
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
#ifdef _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;
|
||||
}
|
||||
} while(still_running);
|
||||
|
||||
/* See how the transfers went */
|
||||
while((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
|
||||
if(msg->msg == CURLMSG_DONE) {
|
||||
printf("HTTP transfer completed with status %d\n", msg->data.result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
/* Free the CURL handles */
|
||||
curl_easy_cleanup(easy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
80
3rd-party/curl-7.52.1/tests/libtest/lib1532.c
vendored
Normal file
80
3rd-party/curl-7.52.1/tests/libtest/lib1532.c
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Test CURLINFO_RESPONSE_CODE */
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
long httpcode;
|
||||
int 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 != 0) {
|
||||
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 res;
|
||||
}
|
200
3rd-party/curl-7.52.1/tests/libtest/lib1533.c
vendored
Normal file
200
3rd-party/curl-7.52.1/tests/libtest/lib1533.c
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* 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(void *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;
|
||||
CURLcode res = CURLE_FAILED_INIT;
|
||||
|
||||
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 == NULL) {
|
||||
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;
|
||||
}
|
||||
|
129
3rd-party/curl-7.52.1/tests/libtest/lib1534.c
vendored
Normal file
129
3rd-party/curl-7.52.1/tests/libtest/lib1534.c
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Test CURLINFO_FILETIME */
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl, *dupe = NULL;
|
||||
long filetime;
|
||||
int 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 res;
|
||||
}
|
128
3rd-party/curl-7.52.1/tests/libtest/lib1535.c
vendored
Normal file
128
3rd-party/curl-7.52.1/tests/libtest/lib1535.c
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Test CURLINFO_PROTOCOL */
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl, *dupe = NULL;
|
||||
long protocol;
|
||||
int 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 != 0) {
|
||||
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 %ld 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 != 0) {
|
||||
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 != 0) {
|
||||
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 res;
|
||||
}
|
129
3rd-party/curl-7.52.1/tests/libtest/lib1536.c
vendored
Normal file
129
3rd-party/curl-7.52.1/tests/libtest/lib1536.c
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Test CURLINFO_SCHEME */
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl, *dupe = NULL;
|
||||
char *scheme;
|
||||
int 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 != NULL) {
|
||||
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(memcmp(scheme, "HTTP", 5) != 0) {
|
||||
fprintf(stderr, "%s:%d scheme of http resource is incorrect; "
|
||||
"expected 'HTTP' but is %s\n",
|
||||
__FILE__, __LINE__, CURLPROTO_HTTP,
|
||||
(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 != 0) {
|
||||
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 != 0) {
|
||||
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 res;
|
||||
}
|
250
3rd-party/curl-7.52.1/tests/libtest/lib1900.c
vendored
Normal file
250
3rd-party/curl-7.52.1/tests/libtest/lib1900.c
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2013 - 2016, 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.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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
#define MAX_URLS 200
|
||||
#define MAX_BLACKLIST 20
|
||||
|
||||
int urltime[MAX_URLS];
|
||||
char *urlstring[MAX_URLS];
|
||||
CURL *handles[MAX_URLS];
|
||||
char *site_blacklist[MAX_BLACKLIST];
|
||||
char *server_blacklist[MAX_BLACKLIST];
|
||||
int num_handles;
|
||||
int blacklist_num_servers;
|
||||
int blacklist_num_sites;
|
||||
|
||||
static size_t
|
||||
write_callback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
(void)contents;
|
||||
(void)userp;
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
static int parse_url_file(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int filetime;
|
||||
char buf[200];
|
||||
|
||||
num_handles = 0;
|
||||
blacklist_num_sites = 0;
|
||||
blacklist_num_servers = 0;
|
||||
|
||||
f = fopen(filename, "rb");
|
||||
if(!f)
|
||||
return 0;
|
||||
|
||||
while(!feof(f)) {
|
||||
if(fscanf(f, "%d %s\n", &filetime, buf)) {
|
||||
urltime[num_handles] = filetime;
|
||||
urlstring[num_handles] = strdup(buf);
|
||||
num_handles++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(fscanf(f, "blacklist_site %s\n", buf)) {
|
||||
site_blacklist[blacklist_num_sites] = strdup(buf);
|
||||
blacklist_num_sites++;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
site_blacklist[blacklist_num_sites] = NULL;
|
||||
server_blacklist[blacklist_num_servers] = NULL;
|
||||
return num_handles;
|
||||
}
|
||||
|
||||
static void free_urls(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0;i < num_handles;i++) {
|
||||
Curl_safefree(urlstring[i]);
|
||||
}
|
||||
for(i = 0;i < blacklist_num_servers;i++) {
|
||||
Curl_safefree(server_blacklist[i]);
|
||||
}
|
||||
for(i = 0;i < blacklist_num_sites;i++) {
|
||||
Curl_safefree(site_blacklist[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static int create_handles(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0;i < num_handles;i++) {
|
||||
handles[i] = curl_easy_init();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup_handle(char *base_url, CURLM *m, int handlenum)
|
||||
{
|
||||
char urlbuf[256];
|
||||
|
||||
snprintf(urlbuf, sizeof(urlbuf), "%s%s", base_url, urlstring[handlenum]);
|
||||
curl_easy_setopt(handles[handlenum], CURLOPT_URL, urlbuf);
|
||||
curl_easy_setopt(handles[handlenum], CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(handles[handlenum], CURLOPT_FAILONERROR, 1L);
|
||||
curl_easy_setopt(handles[handlenum], CURLOPT_WRITEFUNCTION, write_callback);
|
||||
curl_easy_setopt(handles[handlenum], CURLOPT_WRITEDATA, NULL);
|
||||
curl_multi_add_handle(m, handles[handlenum]);
|
||||
}
|
||||
|
||||
static void remove_handles(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0;i < num_handles;i++) {
|
||||
if(handles[i])
|
||||
curl_easy_cleanup(handles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res = 0;
|
||||
CURLM *m = NULL;
|
||||
CURLMsg *msg; /* for picking up messages with the transfer status */
|
||||
int msgs_left; /* how many messages are left */
|
||||
int running;
|
||||
int handlenum = 0;
|
||||
struct timeval last_handle_add;
|
||||
|
||||
if(parse_url_file("log/urls.txt") <= 0)
|
||||
goto test_cleanup;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
multi_init(m);
|
||||
|
||||
create_handles();
|
||||
|
||||
multi_setopt(m, CURLMOPT_PIPELINING, 1L);
|
||||
multi_setopt(m, CURLMOPT_MAX_HOST_CONNECTIONS, 2L);
|
||||
multi_setopt(m, CURLMOPT_MAX_PIPELINE_LENGTH, 3L);
|
||||
multi_setopt(m, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, 15000L);
|
||||
multi_setopt(m, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, 10000L);
|
||||
|
||||
multi_setopt(m, CURLMOPT_PIPELINING_SITE_BL, site_blacklist);
|
||||
multi_setopt(m, CURLMOPT_PIPELINING_SERVER_BL, server_blacklist);
|
||||
|
||||
last_handle_add = tutil_tvnow();
|
||||
|
||||
for(;;) {
|
||||
struct timeval interval;
|
||||
struct timeval now;
|
||||
long int msnow, mslast;
|
||||
fd_set rd, wr, exc;
|
||||
int maxfd = -99;
|
||||
long timeout;
|
||||
|
||||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if(handlenum < num_handles) {
|
||||
now = tutil_tvnow();
|
||||
msnow = now.tv_sec * 1000 + now.tv_usec / 1000;
|
||||
mslast = last_handle_add.tv_sec * 1000 + last_handle_add.tv_usec / 1000;
|
||||
if((msnow - mslast) >= urltime[handlenum]) {
|
||||
fprintf(stdout, "Adding handle %d\n", handlenum);
|
||||
setup_handle(URL, m, handlenum);
|
||||
last_handle_add = now;
|
||||
handlenum++;
|
||||
}
|
||||
}
|
||||
|
||||
curl_multi_perform(m, &running);
|
||||
|
||||
abort_on_test_timeout();
|
||||
|
||||
/* See how the transfers went */
|
||||
while((msg = curl_multi_info_read(m, &msgs_left))) {
|
||||
if(msg->msg == CURLMSG_DONE) {
|
||||
int i, found = 0;
|
||||
|
||||
/* Find out which handle this message is about */
|
||||
for(i = 0; i < num_handles; i++) {
|
||||
found = (msg->easy_handle == handles[i]);
|
||||
if(found)
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Handle %d Completed with status %d\n", i, msg->data.result);
|
||||
curl_multi_remove_handle(m, handles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(handlenum == num_handles && !running) {
|
||||
break; /* done */
|
||||
}
|
||||
|
||||
FD_ZERO(&rd);
|
||||
FD_ZERO(&wr);
|
||||
FD_ZERO(&exc);
|
||||
|
||||
curl_multi_fdset(m, &rd, &wr, &exc, &maxfd);
|
||||
|
||||
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
|
||||
|
||||
curl_multi_timeout(m, &timeout);
|
||||
|
||||
if(timeout < 0)
|
||||
timeout = 1;
|
||||
|
||||
interval.tv_sec = timeout / 1000;
|
||||
interval.tv_usec = (timeout % 1000) * 1000;
|
||||
|
||||
interval.tv_sec = 0;
|
||||
interval.tv_usec = 1000;
|
||||
|
||||
select_test(maxfd+1, &rd, &wr, &exc, &interval);
|
||||
|
||||
abort_on_test_timeout();
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
remove_handles();
|
||||
|
||||
/* undocumented cleanup sequence - type UB */
|
||||
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
free_urls();
|
||||
return res;
|
||||
}
|
143
3rd-party/curl-7.52.1/tests/libtest/lib500.c
vendored
Normal file
143
3rd-party/curl-7.52.1/tests/libtest/lib500.c
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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) {
|
||||
double time_namelookup;
|
||||
double time_connect;
|
||||
double time_pretransfer;
|
||||
double time_starttransfer;
|
||||
double time_total;
|
||||
fprintf(moo, "IP: %s\n", ipstr);
|
||||
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup);
|
||||
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect);
|
||||
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer);
|
||||
curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME,
|
||||
&time_starttransfer);
|
||||
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &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: %f %f\n",
|
||||
time_namelookup, time_connect);
|
||||
}
|
||||
if(time_connect > time_pretransfer) {
|
||||
fprintf(moo, "connect vs pretransfer: %f %f\n",
|
||||
time_connect, time_pretransfer);
|
||||
}
|
||||
if(time_pretransfer > time_starttransfer) {
|
||||
fprintf(moo, "pretransfer vs starttransfer: %f %f\n",
|
||||
time_pretransfer, time_starttransfer);
|
||||
}
|
||||
if(time_starttransfer > time_total) {
|
||||
fprintf(moo, "starttransfer vs total: %f %f\n",
|
||||
time_starttransfer, time_total);
|
||||
}
|
||||
|
||||
fclose(moo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
56
3rd-party/curl-7.52.1/tests/libtest/lib501.c
vendored
Normal file
56
3rd-party/curl-7.52.1/tests/libtest/lib501.c
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
92
3rd-party/curl-7.52.1/tests/libtest/lib502.c
vendored
Normal file
92
3rd-party/curl-7.52.1/tests/libtest/lib502.c
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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;
|
||||
}
|
||||
|
102
3rd-party/curl-7.52.1/tests/libtest/lib503.c
vendored
Normal file
102
3rd-party/curl-7.52.1/tests/libtest/lib503.c
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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;
|
||||
}
|
||||
|
114
3rd-party/curl-7.52.1/tests/libtest/lib504.c
vendored
Normal file
114
3rd-party/curl-7.52.1/tests/libtest/lib504.c
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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;
|
||||
}
|
||||
|
153
3rd-party/curl-7.52.1/tests/libtest/lib505.c
vendored
Normal file
153
3rd-party/curl-7.52.1/tests/libtest/lib505.c
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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;
|
||||
int error;
|
||||
|
||||
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(NULL == hd_src) {
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fopen failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
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 */
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fstat() failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
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;
|
||||
}
|
380
3rd-party/curl-7.52.1/tests/libtest/lib506.c
vendored
Normal file
380
3rd-party/curl-7.52.1/tests/libtest/lib506.c
vendored
Normal file
@@ -0,0 +1,380 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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 {
|
||||
char *text;
|
||||
int counter;
|
||||
};
|
||||
|
||||
int lock[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(lock[locknum]) {
|
||||
printf("lock: double locked %s\n", what);
|
||||
return;
|
||||
}
|
||||
lock[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(!lock[locknum]) {
|
||||
printf("unlock: double unlocked %s\n", what);
|
||||
return;
|
||||
}
|
||||
lock[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;
|
||||
int i=0;
|
||||
|
||||
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);
|
||||
printf("CURLOPT_SHARE\n");
|
||||
curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
|
||||
|
||||
printf("PERFORM\n");
|
||||
code = curl_easy_perform(curl);
|
||||
if(code) {
|
||||
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 = (char *)"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;
|
||||
}
|
||||
|
100
3rd-party/curl-7.52.1/tests/libtest/lib507.c
vendored
Normal file
100
3rd-party/curl-7.52.1/tests/libtest/lib507.c
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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 */
|
||||
}
|
108
3rd-party/curl-7.52.1/tests/libtest/lib508.c
vendored
Normal file
108
3rd-party/curl-7.52.1/tests/libtest/lib508.c
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
struct WriteThis *pooh = (struct WriteThis *)userp;
|
||||
|
||||
if(size*nmemb < 1)
|
||||
return 0;
|
||||
|
||||
if(pooh->sizeleft) {
|
||||
*(char *)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);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
}
|
147
3rd-party/curl-7.52.1/tests/libtest/lib509.c
vendored
Normal file
147
3rd-party/curl-7.52.1/tests/libtest/lib509.c
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* This test uses these funny custom memory callbacks for the only purpose
|
||||
* of verifying that curl_global_init_mem() functionallity 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'.
|
||||
*/
|
||||
|
||||
/*
|
||||
#include "memdebug.h"
|
||||
*/
|
||||
|
||||
int seen_malloc = 0;
|
||||
int seen_free = 0;
|
||||
int seen_realloc = 0;
|
||||
int seen_strdup = 0;
|
||||
int seen_calloc = 0;
|
||||
|
||||
void *custom_malloc(size_t size);
|
||||
void custom_free(void *ptr);
|
||||
void *custom_realloc(void *ptr, size_t size);
|
||||
char *custom_strdup(const char *ptr);
|
||||
void *custom_calloc(size_t nmemb, size_t size);
|
||||
|
||||
|
||||
void *custom_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
if(!seen_calloc) {
|
||||
printf("seen custom_calloc()\n");
|
||||
seen_calloc = 1;
|
||||
}
|
||||
return (calloc)(nmemb, size);
|
||||
}
|
||||
|
||||
void *custom_malloc(size_t size)
|
||||
{
|
||||
if(!seen_malloc && seen_calloc) {
|
||||
printf("seen custom_malloc()\n");
|
||||
seen_malloc = 1;
|
||||
}
|
||||
return (malloc)(size);
|
||||
}
|
||||
|
||||
char *custom_strdup(const char *ptr)
|
||||
{
|
||||
if(!seen_strdup && seen_malloc) {
|
||||
/* currently (2013.03.13), memory tracking enabled builds do not call
|
||||
the strdup callback, in this case malloc callback and memcpy are used
|
||||
instead. If some day this is changed the following printf() should be
|
||||
uncommented, and a line added to test definition.
|
||||
printf("seen custom_strdup()\n");
|
||||
*/
|
||||
seen_strdup = 1;
|
||||
}
|
||||
return (strdup)(ptr);
|
||||
}
|
||||
|
||||
void *custom_realloc(void *ptr, size_t size)
|
||||
{
|
||||
if(!seen_realloc && seen_malloc) {
|
||||
printf("seen custom_realloc()\n");
|
||||
seen_realloc = 1;
|
||||
}
|
||||
return (realloc)(ptr, size);
|
||||
}
|
||||
|
||||
void custom_free(void *ptr)
|
||||
{
|
||||
if(!seen_free && seen_realloc) {
|
||||
printf("seen custom_free()\n");
|
||||
seen_free = 1;
|
||||
}
|
||||
(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() */
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(str)
|
||||
curl_free(str);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
131
3rd-party/curl-7.52.1/tests/libtest/lib510.c
vendored
Normal file
131
3rd-party/curl-7.52.1/tests/libtest/lib510.c
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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(void *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);
|
||||
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 == NULL) {
|
||||
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);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
}
|
56
3rd-party/curl-7.52.1/tests/libtest/lib511.c
vendored
Normal file
56
3rd-party/curl-7.52.1/tests/libtest/lib511.c
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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;
|
||||
}
|
77
3rd-party/curl-7.52.1/tests/libtest/lib512.c
vendored
Normal file
77
3rd-party/curl-7.52.1/tests/libtest/lib512.c
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* Test case code based on source in a bug report filed by James Bursa on
|
||||
28 Apr 2004 */
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode code;
|
||||
CURL *curl;
|
||||
CURL *curl2;
|
||||
int rc = 99;
|
||||
|
||||
code = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if(code == CURLE_OK) {
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
curl2 = curl_easy_duphandle(curl);
|
||||
if(curl2) {
|
||||
|
||||
code = curl_easy_setopt(curl2, CURLOPT_URL, URL);
|
||||
if(code == CURLE_OK) {
|
||||
|
||||
code = curl_easy_perform(curl2);
|
||||
if(code == CURLE_OK)
|
||||
rc = 0;
|
||||
else
|
||||
rc = 1;
|
||||
}
|
||||
else
|
||||
rc = 2;
|
||||
|
||||
curl_easy_cleanup(curl2);
|
||||
}
|
||||
else
|
||||
rc = 3;
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
else
|
||||
rc = 4;
|
||||
|
||||
curl_global_cleanup();
|
||||
}
|
||||
else
|
||||
rc = 5;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
83
3rd-party/curl-7.52.1/tests/libtest/lib513.c
vendored
Normal file
83
3rd-party/curl-7.52.1/tests/libtest/lib513.c
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static size_t read_callback(void *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)
|
||||
{
|
||||
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) {
|
||||
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, 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, NULL);
|
||||
|
||||
/* 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 (int)res;
|
||||
}
|
79
3rd-party/curl-7.52.1/tests/libtest/lib514.c
vendored
Normal file
79
3rd-party/curl-7.52.1/tests/libtest/lib514.c
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.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) {
|
||||
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);
|
||||
|
||||
/* Based on a bug report by Niels van Tongeren on June 29, 2004:
|
||||
|
||||
A weird situation occurs when request 1 is a POST request and the request
|
||||
2 is a HEAD request. For the POST request we set the CURLOPT_POSTFIELDS,
|
||||
CURLOPT_POSTFIELDSIZE and CURLOPT_POST options. For the HEAD request we
|
||||
set the CURLOPT_NOBODY option to '1'.
|
||||
|
||||
*/
|
||||
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, "moo");
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
/* this is where transfer 1 would take place, but skip that and change
|
||||
options right away instead */
|
||||
|
||||
test_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Now, we should be making a fine HEAD request */
|
||||
|
||||
/* Perform the request 2, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
60
3rd-party/curl-7.52.1/tests/libtest/lib515.c
vendored
Normal file
60
3rd-party/curl-7.52.1/tests/libtest/lib515.c
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.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) {
|
||||
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);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Now, we should be making a zero byte POST request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
59
3rd-party/curl-7.52.1/tests/libtest/lib516.c
vendored
Normal file
59
3rd-party/curl-7.52.1/tests/libtest/lib516.c
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.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) {
|
||||
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);
|
||||
test_setopt(curl, CURLOPT_HTTPPOST, NULL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Now, we should be making a zero byte POST request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
139
3rd-party/curl-7.52.1/tests/libtest/lib517.c
vendored
Normal file
139
3rd-party/curl-7.52.1/tests/libtest/lib517.c
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static const char * const dates[]={
|
||||
"Sun, 06 Nov 1994 08:49:37 GMT",
|
||||
"Sunday, 06-Nov-94 08:49:37 GMT",
|
||||
"Sun Nov 6 08:49:37 1994",
|
||||
"06 Nov 1994 08:49:37 GMT",
|
||||
"06-Nov-94 08:49:37 GMT",
|
||||
"Nov 6 08:49:37 1994",
|
||||
"06 Nov 1994 08:49:37",
|
||||
"06-Nov-94 08:49:37",
|
||||
"1994 Nov 6 08:49:37",
|
||||
"GMT 08:49:37 06-Nov-94 Sunday",
|
||||
"94 6 Nov 08:49:37",
|
||||
"1994 Nov 6",
|
||||
"06-Nov-94",
|
||||
"Sun Nov 6 94",
|
||||
"1994.Nov.6",
|
||||
"Sun/Nov/6/94/GMT",
|
||||
"Sun, 06 Nov 1994 08:49:37 CET",
|
||||
"06 Nov 1994 08:49:37 EST",
|
||||
"Sun, 12 Sep 2004 15:05:58 -0700",
|
||||
"Sat, 11 Sep 2004 21:32:11 +0200",
|
||||
"20040912 15:05:58 -0700",
|
||||
"20040911 +0200",
|
||||
"Thu, 01-Jan-1970 00:59:59 GMT",
|
||||
"Thu, 01-Jan-1970 01:00:00 GMT",
|
||||
/* "2094 Nov 6", See ../data/test517 for details */
|
||||
"Sat, 15-Apr-17 21:01:22 GMT",
|
||||
"Thu, 19-Apr-2007 16:00:00 GMT",
|
||||
"Wed, 25 Apr 2007 21:02:13 GMT",
|
||||
"Thu, 19/Apr\\2007 16:00:00 GMT",
|
||||
"Fri, 1 Jan 2010 01:01:50 GMT",
|
||||
"Wednesday, 1-Jan-2003 00:00:00 GMT",
|
||||
", 1-Jan-2003 00:00:00 GMT",
|
||||
" 1-Jan-2003 00:00:00 GMT",
|
||||
"1-Jan-2003 00:00:00 GMT",
|
||||
"Wed,18-Apr-07 22:50:12 GMT",
|
||||
"WillyWonka , 18-Apr-07 22:50:12 GMT",
|
||||
"WillyWonka , 18-Apr-07 22:50:12",
|
||||
"WillyWonka , 18-apr-07 22:50:12",
|
||||
"Mon, 18-Apr-1977 22:50:13 GMT",
|
||||
"Mon, 18-Apr-77 22:50:13 GMT",
|
||||
"\"Sat, 15-Apr-17\\\"21:01:22\\\"GMT\"",
|
||||
"Partyday, 18- April-07 22:50:12",
|
||||
"Partyday, 18 - Apri-07 22:50:12",
|
||||
"Wednes, 1-Januar-2003 00:00:00 GMT",
|
||||
"Sat, 15-Apr-17 21:01:22",
|
||||
"Sat, 15-Apr-17 21:01:22 GMT-2",
|
||||
"Sat, 15-Apr-17 21:01:22 GMT BLAH",
|
||||
"Sat, 15-Apr-17 21:01:22 GMT-0400",
|
||||
"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)",
|
||||
"Sat, 15-Apr-17 21:01:22 DST",
|
||||
"Sat, 15-Apr-17 21:01:22 -0400",
|
||||
"Sat, 15-Apr-17 21:01:22 (hello there)",
|
||||
"Sat, 15-Apr-17 21:01:22 11:22:33",
|
||||
"Sat, 15-Apr-17 ::00 21:01:22",
|
||||
"Sat, 15-Apr-17 boink:z 21:01:22",
|
||||
"Sat, 15-Apr-17 91:22:33 21:01:22",
|
||||
"Thu Apr 18 22:50:12 2007 GMT",
|
||||
"22:50:12 Thu Apr 18 2007 GMT",
|
||||
"Thu 22:50:12 Apr 18 2007 GMT",
|
||||
"Thu Apr 22:50:12 18 2007 GMT",
|
||||
"Thu Apr 18 22:50:12 2007 GMT",
|
||||
"Thu Apr 18 2007 22:50:12 GMT",
|
||||
"Thu Apr 18 2007 GMT 22:50:12",
|
||||
"Sat, 15-Apr-17 21:01:22 GMT",
|
||||
"15-Sat, Apr-17 21:01:22 GMT",
|
||||
"15-Sat, Apr 21:01:22 GMT 17",
|
||||
"15-Sat, Apr 21:01:22 GMT 2017",
|
||||
"15 Apr 21:01:22 2017",
|
||||
"15 17 Apr 21:01:22",
|
||||
"Apr 15 17 21:01:22",
|
||||
"Apr 15 21:01:22 17",
|
||||
"2017 April 15 21:01:22",
|
||||
"15 April 2017 21:01:22",
|
||||
"98 April 17 21:01:22",
|
||||
"Thu, 012-Aug-2008 20:49:07 GMT",
|
||||
#if 0
|
||||
/* leaving out these strings since they differ between 32 and 64 bit
|
||||
archs and the test suite has no good way to support two different outputs
|
||||
like that */
|
||||
"Thu, 12-Aug-31841 20:49:07 GMT",
|
||||
"Thu, 12-Aug-9999999999 20:49:07 GMT",
|
||||
#endif
|
||||
"Thu, 999999999999-Aug-2007 20:49:07 GMT",
|
||||
"Thu, 12-Aug-2007 20:61:99999999999 GMT",
|
||||
"IAintNoDateFool",
|
||||
"Thu Apr 18 22:50 2007 GMT", /* without seconds */
|
||||
"20110623 12:34:56",
|
||||
"20110632 12:34:56",
|
||||
"20110623 56:34:56",
|
||||
"20111323 12:34:56",
|
||||
"20110623 12:34:79",
|
||||
"Wed, 31 Dec 2008 23:59:60 GMT", /* leap second */
|
||||
"20110623 12:3",
|
||||
"20110623 1:3",
|
||||
"20110623 1:30",
|
||||
"20110623 12:12:3",
|
||||
"20110623 01:12:3",
|
||||
"20110623 01:99:30",
|
||||
NULL
|
||||
};
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int i;
|
||||
|
||||
(void)URL; /* not used */
|
||||
|
||||
for(i=0; dates[i]; i++) {
|
||||
printf("%d: %s => %ld\n", i, dates[i], (long)curl_getdate(dates[i], NULL));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
523
3rd-party/curl-7.52.1/tests/libtest/lib518.c
vendored
Normal file
523
3rd-party/curl-7.52.1/tests/libtest/lib518.c
vendored
Normal file
@@ -0,0 +1,523 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef FD_SETSIZE
|
||||
#error "this test requires FD_SETSIZE"
|
||||
#endif
|
||||
|
||||
#define SAFETY_MARGIN (16)
|
||||
#define NUM_OPEN (FD_SETSIZE + 10)
|
||||
#define NUM_NEEDED (NUM_OPEN + SAFETY_MARGIN)
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(MSDOS)
|
||||
#define DEV_NULL "NUL"
|
||||
#else
|
||||
#define DEV_NULL "/dev/null"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
|
||||
|
||||
static int *fd = NULL;
|
||||
static struct rlimit num_open;
|
||||
static char msgbuff[256];
|
||||
|
||||
static void store_errmsg(const char *msg, int err)
|
||||
{
|
||||
if(!err)
|
||||
snprintf(msgbuff, sizeof(msgbuff), "%s", msg);
|
||||
else
|
||||
snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg,
|
||||
err, strerror(err));
|
||||
}
|
||||
|
||||
static void close_file_descriptors(void)
|
||||
{
|
||||
for(num_open.rlim_cur = 0;
|
||||
num_open.rlim_cur < num_open.rlim_max;
|
||||
num_open.rlim_cur++)
|
||||
if(fd[num_open.rlim_cur] > 0)
|
||||
close(fd[num_open.rlim_cur]);
|
||||
free(fd);
|
||||
fd = NULL;
|
||||
}
|
||||
|
||||
static int fopen_works(void)
|
||||
{
|
||||
FILE *fpa[3];
|
||||
int i;
|
||||
int ret = 1;
|
||||
|
||||
for(i = 0; i < 3; i++) {
|
||||
fpa[i] = NULL;
|
||||
}
|
||||
for(i = 0; i < 3; i++) {
|
||||
fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
|
||||
if(fpa[i] == NULL) {
|
||||
store_errmsg("fopen failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < 3; i++) {
|
||||
if(fpa[i] != NULL)
|
||||
fclose(fpa[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rlimit(int keep_open)
|
||||
{
|
||||
int nitems, i;
|
||||
int *memchunk = NULL;
|
||||
char *fmt;
|
||||
struct rlimit rl;
|
||||
char strbuff[256];
|
||||
char strbuff1[81];
|
||||
char strbuff2[81];
|
||||
char fmt_u[] = "%u";
|
||||
char fmt_lu[] = "%lu";
|
||||
#ifdef HAVE_LONGLONG
|
||||
char fmt_llu[] = "%llu";
|
||||
|
||||
if(sizeof(rl.rlim_max) > sizeof(long))
|
||||
fmt = fmt_llu;
|
||||
else
|
||||
#endif
|
||||
fmt = (sizeof(rl.rlim_max) < sizeof(long))?fmt_u:fmt_lu;
|
||||
|
||||
/* get initial open file limits */
|
||||
|
||||
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
store_errmsg("getrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* show initial open file limits */
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_cur == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur);
|
||||
fprintf(stderr, "initial soft limit: %s\n", strbuff);
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_max == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max);
|
||||
fprintf(stderr, "initial hard limit: %s\n", strbuff);
|
||||
|
||||
/* show our constants */
|
||||
|
||||
fprintf(stderr, "test518 FD_SETSIZE: %d\n", FD_SETSIZE);
|
||||
fprintf(stderr, "test518 NUM_OPEN : %d\n", NUM_OPEN);
|
||||
fprintf(stderr, "test518 NUM_NEEDED: %d\n", NUM_NEEDED);
|
||||
|
||||
/*
|
||||
* if soft limit and hard limit are different we ask the
|
||||
* system to raise soft limit all the way up to the hard
|
||||
* limit. Due to some other system limit the soft limit
|
||||
* might not be raised up to the hard limit. So from this
|
||||
* point the resulting soft limit is our limit. Trying to
|
||||
* open more than soft limit file descriptors will fail.
|
||||
*/
|
||||
|
||||
if(rl.rlim_cur != rl.rlim_max) {
|
||||
|
||||
#ifdef OPEN_MAX
|
||||
if((rl.rlim_cur > 0) &&
|
||||
(rl.rlim_cur < OPEN_MAX)) {
|
||||
fprintf(stderr, "raising soft limit up to OPEN_MAX\n");
|
||||
rl.rlim_cur = OPEN_MAX;
|
||||
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
/* on failure don't abort just issue a warning */
|
||||
store_errmsg("setrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
msgbuff[0] = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "raising soft limit up to hard limit\n");
|
||||
rl.rlim_cur = rl.rlim_max;
|
||||
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
/* on failure don't abort just issue a warning */
|
||||
store_errmsg("setrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
msgbuff[0] = '\0';
|
||||
}
|
||||
|
||||
/* get current open file limits */
|
||||
|
||||
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
store_errmsg("getrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* show current open file limits */
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_cur == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur);
|
||||
fprintf(stderr, "current soft limit: %s\n", strbuff);
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_max == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max);
|
||||
fprintf(stderr, "current hard limit: %s\n", strbuff);
|
||||
|
||||
} /* (rl.rlim_cur != rl.rlim_max) */
|
||||
|
||||
/*
|
||||
* test 518 is all about testing libcurl functionality
|
||||
* when more than FD_SETSIZE file descriptors are open.
|
||||
* This means that if for any reason we are not able to
|
||||
* open more than FD_SETSIZE file descriptors then test
|
||||
* 518 should not be run.
|
||||
*/
|
||||
|
||||
/*
|
||||
* verify that soft limit is higher than NUM_NEEDED,
|
||||
* which is the number of file descriptors we would
|
||||
* try to open plus SAFETY_MARGIN to not exhaust the
|
||||
* file descriptor pool
|
||||
*/
|
||||
|
||||
num_open.rlim_cur = NUM_NEEDED;
|
||||
|
||||
if((rl.rlim_cur > 0) &&
|
||||
#ifdef RLIM_INFINITY
|
||||
(rl.rlim_cur != RLIM_INFINITY) &&
|
||||
#endif
|
||||
(rl.rlim_cur <= num_open.rlim_cur)) {
|
||||
snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur);
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
|
||||
snprintf(strbuff, sizeof(strbuff), "fds needed %s > system limit %s",
|
||||
strbuff1, strbuff2);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
return -4;
|
||||
}
|
||||
|
||||
/*
|
||||
* reserve a chunk of memory before opening file descriptors to
|
||||
* avoid a low memory condition once the file descriptors are
|
||||
* open. System conditions that could make the test fail should
|
||||
* be addressed in the precheck phase. This chunk of memory shall
|
||||
* be always free()ed before exiting the rlimit() function so
|
||||
* that it becomes available to the test.
|
||||
*/
|
||||
|
||||
for(nitems = i = 1; nitems <= i; i *= 2)
|
||||
nitems = i;
|
||||
if(nitems > 0x7fff)
|
||||
nitems = 0x40000;
|
||||
do {
|
||||
num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems;
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
|
||||
memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
|
||||
if(!memchunk) {
|
||||
fprintf(stderr, "memchunk, malloc() failed\n");
|
||||
nitems /= 2;
|
||||
}
|
||||
} while(nitems && !memchunk);
|
||||
if(!memchunk) {
|
||||
store_errmsg("memchunk, malloc() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
return -5;
|
||||
}
|
||||
|
||||
/* initialize it to fight lazy allocation */
|
||||
|
||||
fprintf(stderr, "initializing memchunk array\n");
|
||||
|
||||
for(i = 0; i < nitems; i++)
|
||||
memchunk[i] = -1;
|
||||
|
||||
/* set the number of file descriptors we will try to open */
|
||||
|
||||
num_open.rlim_max = NUM_OPEN;
|
||||
|
||||
/* verify that we won't overflow size_t in malloc() */
|
||||
|
||||
if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) {
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max);
|
||||
snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s "
|
||||
"file descriptors, would overflow size_t", strbuff1);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
free(memchunk);
|
||||
return -6;
|
||||
}
|
||||
|
||||
/* allocate array for file descriptors */
|
||||
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "allocating array for %s file descriptors\n", strbuff);
|
||||
|
||||
fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max));
|
||||
if(!fd) {
|
||||
store_errmsg("fd, malloc() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
free(memchunk);
|
||||
return -7;
|
||||
}
|
||||
|
||||
/* initialize it to fight lazy allocation */
|
||||
|
||||
fprintf(stderr, "initializing fd array\n");
|
||||
|
||||
for(num_open.rlim_cur = 0;
|
||||
num_open.rlim_cur < num_open.rlim_max;
|
||||
num_open.rlim_cur++)
|
||||
fd[num_open.rlim_cur] = -1;
|
||||
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "trying to open %s file descriptors\n", strbuff);
|
||||
|
||||
/* open a dummy descriptor */
|
||||
|
||||
fd[0] = open(DEV_NULL, O_RDONLY);
|
||||
if(fd[0] < 0) {
|
||||
snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
|
||||
store_errmsg(strbuff, ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
free(fd);
|
||||
fd = NULL;
|
||||
free(memchunk);
|
||||
return -8;
|
||||
}
|
||||
|
||||
/* create a bunch of file descriptors */
|
||||
|
||||
for(num_open.rlim_cur = 1;
|
||||
num_open.rlim_cur < num_open.rlim_max;
|
||||
num_open.rlim_cur++) {
|
||||
|
||||
fd[num_open.rlim_cur] = dup(fd[0]);
|
||||
|
||||
if(fd[num_open.rlim_cur] < 0) {
|
||||
|
||||
fd[num_open.rlim_cur] = -1;
|
||||
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
|
||||
snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1);
|
||||
fprintf(stderr, "%s\n", strbuff);
|
||||
|
||||
snprintf(strbuff1, sizeof(strbuff), fmt, num_open.rlim_cur);
|
||||
snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s",
|
||||
strbuff1);
|
||||
fprintf(stderr, "%s\n", strbuff);
|
||||
|
||||
num_open.rlim_max = NUM_NEEDED;
|
||||
|
||||
snprintf(strbuff2, sizeof(strbuff2), fmt, num_open.rlim_max);
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
|
||||
snprintf(strbuff, sizeof(strbuff), "fds needed %s > system limit %s",
|
||||
strbuff2, strbuff1);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
|
||||
for(num_open.rlim_cur = 0;
|
||||
fd[num_open.rlim_cur] >= 0;
|
||||
num_open.rlim_cur++)
|
||||
close(fd[num_open.rlim_cur]);
|
||||
free(fd);
|
||||
fd = NULL;
|
||||
free(memchunk);
|
||||
return -9;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "%s file descriptors open\n", strbuff);
|
||||
|
||||
#if !defined(HAVE_POLL_FINE) && \
|
||||
!defined(USE_WINSOCK) && \
|
||||
!defined(TPF)
|
||||
|
||||
/*
|
||||
* when using select() instead of poll() we cannot test
|
||||
* libcurl functionality with a socket number equal or
|
||||
* greater than FD_SETSIZE. In any case, macro VERIFY_SOCK
|
||||
* in lib/select.c enforces this check and protects libcurl
|
||||
* from a possible crash. The effect of this protection
|
||||
* is that test 518 will always fail, since the actual
|
||||
* call to select() never takes place. We skip test 518
|
||||
* with an indication that select limit would be exceeded.
|
||||
*/
|
||||
|
||||
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
|
||||
if(num_open.rlim_max > num_open.rlim_cur) {
|
||||
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
|
||||
FD_SETSIZE);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
close_file_descriptors();
|
||||
free(memchunk);
|
||||
return -10;
|
||||
}
|
||||
|
||||
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
|
||||
for(rl.rlim_cur = 0;
|
||||
rl.rlim_cur < num_open.rlim_max;
|
||||
rl.rlim_cur++) {
|
||||
if((fd[rl.rlim_cur] > 0) &&
|
||||
((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) {
|
||||
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
|
||||
FD_SETSIZE);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
close_file_descriptors();
|
||||
free(memchunk);
|
||||
return -11;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* using a FD_SETSIZE bound select() */
|
||||
|
||||
/*
|
||||
* Old or 'backwards compatible' implementations of stdio do not allow
|
||||
* handling of streams with an underlying file descriptor number greater
|
||||
* than 255, even when allowing high numbered file descriptors for sockets.
|
||||
* At this point we have a big number of file descriptors which have been
|
||||
* opened using dup(), so lets test the stdio implementation and discover
|
||||
* if it is capable of fopen()ing some additional files.
|
||||
*/
|
||||
|
||||
if(!fopen_works()) {
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max);
|
||||
snprintf(strbuff, sizeof(strbuff),
|
||||
"fopen fails with %s fds open()",
|
||||
strbuff1);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
snprintf(strbuff, sizeof(strbuff),
|
||||
"fopen fails with lots of fds open()");
|
||||
store_errmsg(strbuff, 0);
|
||||
close_file_descriptors();
|
||||
free(memchunk);
|
||||
return -12;
|
||||
}
|
||||
|
||||
/* free the chunk of memory we were reserving so that it
|
||||
becomes becomes available to the test */
|
||||
|
||||
free(memchunk);
|
||||
|
||||
/* close file descriptors unless instructed to keep them */
|
||||
|
||||
if(!keep_open) {
|
||||
close_file_descriptors();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
|
||||
if(!strcmp(URL, "check")) {
|
||||
/* used by the test script to ask if we can run this test or not */
|
||||
if(rlimit(FALSE)) {
|
||||
fprintf(stdout, "rlimit problem: %s\n", msgbuff);
|
||||
return 1;
|
||||
}
|
||||
return 0; /* sure, run this! */
|
||||
}
|
||||
|
||||
if(rlimit(TRUE)) {
|
||||
/* failure */
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
/* run the test with the bunch of open file descriptors
|
||||
and close them all once the test is over */
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
close_file_descriptors();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
close_file_descriptors();
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
close_file_descriptors();
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
#else /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
(void)URL;
|
||||
printf("system lacks necessary system function(s)");
|
||||
return 1; /* skip test */
|
||||
}
|
||||
|
||||
#endif /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
|
63
3rd-party/curl-7.52.1/tests/libtest/lib519.c
vendored
Normal file
63
3rd-party/curl-7.52.1/tests/libtest/lib519.c
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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_USERPWD, "monster:underbed");
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* get first page */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe");
|
||||
|
||||
/* get second page */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
55
3rd-party/curl-7.52.1/tests/libtest/lib520.c
vendored
Normal file
55
3rd-party/curl-7.52.1/tests/libtest/lib520.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
57
3rd-party/curl-7.52.1/tests/libtest/lib521.c
vendored
Normal file
57
3rd-party/curl-7.52.1/tests/libtest/lib521.c
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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_PORT, strtol(libtest_arg2, NULL, 10));
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
58
3rd-party/curl-7.52.1/tests/libtest/lib523.c
vendored
Normal file
58
3rd-party/curl-7.52.1/tests/libtest/lib523.c
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_PORT, 19999L);
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
56
3rd-party/curl-7.52.1/tests/libtest/lib524.c
vendored
Normal file
56
3rd-party/curl-7.52.1/tests/libtest/lib524.c
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
165
3rd-party/curl-7.52.1/tests/libtest/lib525.c
vendored
Normal file
165
3rd-party/curl-7.52.1/tests/libtest/lib525.c
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res = 0;
|
||||
CURL *curl = NULL;
|
||||
FILE *hd_src = NULL;
|
||||
int hd;
|
||||
int error;
|
||||
struct_stat file_info;
|
||||
CURLM *m = NULL;
|
||||
int running;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
if(!libtest_arg2) {
|
||||
#ifdef LIB529
|
||||
/* test 529 */
|
||||
fprintf(stderr, "Usage: lib529 [url] [uploadfile]\n");
|
||||
#else
|
||||
/* test 525 */
|
||||
fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n");
|
||||
#endif
|
||||
return TEST_ERR_USAGE;
|
||||
}
|
||||
|
||||
hd_src = fopen(libtest_arg2, "rb");
|
||||
if(NULL == hd_src) {
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fopen failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
|
||||
return TEST_ERR_FOPEN;
|
||||
}
|
||||
|
||||
/* get the file size of the local file */
|
||||
hd = fstat(fileno(hd_src), &file_info);
|
||||
if(hd == -1) {
|
||||
/* can't open file, bail out */
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
|
||||
fclose(hd_src);
|
||||
return TEST_ERR_FSTAT;
|
||||
}
|
||||
|
||||
res_global_init(CURL_GLOBAL_ALL);
|
||||
if(res) {
|
||||
fclose(hd_src);
|
||||
return res;
|
||||
}
|
||||
|
||||
easy_init(curl);
|
||||
|
||||
/* enable uploading */
|
||||
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* specify target */
|
||||
easy_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* go verbose */
|
||||
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* use active FTP */
|
||||
easy_setopt(curl, CURLOPT_FTPPORT, "-");
|
||||
|
||||
/* now specify which file to upload */
|
||||
easy_setopt(curl, CURLOPT_READDATA, hd_src);
|
||||
|
||||
/* NOTE: if you want this code to work on Windows with libcurl as a DLL, you
|
||||
MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
|
||||
do so will give you a crash since a DLL may not use the variable's memory
|
||||
when passed in to it from an app like this. */
|
||||
|
||||
/* Set the size of the file to upload (optional). If you give a *_LARGE
|
||||
option you MUST make sure that the type of the passed-in argument is a
|
||||
curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
|
||||
make sure that to pass in a type 'long' argument. */
|
||||
easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
|
||||
|
||||
multi_init(m);
|
||||
|
||||
multi_add_handle(m, curl);
|
||||
|
||||
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:
|
||||
|
||||
#ifdef LIB529
|
||||
/* test 529 */
|
||||
/* proper cleanup sequence - type PA */
|
||||
curl_multi_remove_handle(m, curl);
|
||||
curl_multi_cleanup(m);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
#else
|
||||
/* test 525 */
|
||||
/* proper cleanup sequence - type PB */
|
||||
curl_multi_remove_handle(m, curl);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
#endif
|
||||
|
||||
/* close the local file */
|
||||
fclose(hd_src);
|
||||
|
||||
return res;
|
||||
}
|
184
3rd-party/curl-7.52.1/tests/libtest/lib526.c
vendored
Normal file
184
3rd-party/curl-7.52.1/tests/libtest/lib526.c
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
* This code sets up multiple easy handles that transfer a single file from
|
||||
* the same URL, in a serial manner after each other. Due to the connection
|
||||
* sharing within the multi handle all transfers are performed on the same
|
||||
* persistent connection.
|
||||
*
|
||||
* This source code is used for lib526, lib527 and lib532 with only #ifdefs
|
||||
* controlling the small differences.
|
||||
*
|
||||
* - lib526 closes all easy handles after
|
||||
* they all have transfered the file over the single connection
|
||||
* - lib527 closes each easy handle after each single transfer.
|
||||
* - lib532 uses only a single easy handle that is removed, reset and then
|
||||
* re-added for each transfer
|
||||
*
|
||||
* Test case 526, 527 and 532 use FTP, while test 528 uses the lib526 tool but
|
||||
* with HTTP.
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include <fcntl.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];
|
||||
int running;
|
||||
CURLM *m = NULL;
|
||||
int current = 0;
|
||||
int i;
|
||||
|
||||
for(i=0; i < NUM_HANDLES; i++)
|
||||
curl[i] = NULL;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
/* get NUM_HANDLES easy handles */
|
||||
for(i=0; i < NUM_HANDLES; i++) {
|
||||
easy_init(curl[i]);
|
||||
/* specify target */
|
||||
easy_setopt(curl[i], CURLOPT_URL, URL);
|
||||
/* go verbose */
|
||||
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
|
||||
}
|
||||
|
||||
multi_init(m);
|
||||
|
||||
multi_add_handle(m, curl[current]);
|
||||
|
||||
fprintf(stderr, "Start at URL 0\n");
|
||||
|
||||
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) {
|
||||
#ifdef LIB527
|
||||
/* NOTE: this code does not remove the handle from the multi handle
|
||||
here, which would be the nice, sane and documented way of working.
|
||||
This however tests that the API survives this abuse gracefully. */
|
||||
curl_easy_cleanup(curl[current]);
|
||||
curl[current] = NULL;
|
||||
#endif
|
||||
if(++current < NUM_HANDLES) {
|
||||
fprintf(stderr, "Advancing to URL %d\n", current);
|
||||
#ifdef LIB532
|
||||
/* first remove the only handle we use */
|
||||
curl_multi_remove_handle(m, curl[0]);
|
||||
|
||||
/* make us re-use the same handle all the time, and try resetting
|
||||
the handle first too */
|
||||
curl_easy_reset(curl[0]);
|
||||
easy_setopt(curl[0], CURLOPT_URL, URL);
|
||||
/* go verbose */
|
||||
easy_setopt(curl[0], CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* re-add it */
|
||||
multi_add_handle(m, curl[0]);
|
||||
#else
|
||||
multi_add_handle(m, curl[current]);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
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:
|
||||
|
||||
#if defined(LIB526)
|
||||
|
||||
/* test 526 and 528 */
|
||||
/* 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_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
#elif defined(LIB527)
|
||||
|
||||
/* test 527 */
|
||||
|
||||
/* Upon non-failure test flow the easy's have already been cleanup'ed. In
|
||||
case there is a failure we arrive here with easy's that have not been
|
||||
cleanup'ed yet, in this case we have to cleanup them or otherwise these
|
||||
will be leaked, let's use undocumented cleanup sequence - type UB */
|
||||
|
||||
if(res)
|
||||
for(i=0; i < NUM_HANDLES; i++)
|
||||
curl_easy_cleanup(curl[i]);
|
||||
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
#elif defined(LIB532)
|
||||
|
||||
/* test 532 */
|
||||
/* undocumented cleanup sequence - type UB */
|
||||
|
||||
for(i=0; i < NUM_HANDLES; i++)
|
||||
curl_easy_cleanup(curl[i]);
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
122
3rd-party/curl-7.52.1/tests/libtest/lib530.c
vendored
Normal file
122
3rd-party/curl-7.52.1/tests/libtest/lib530.c
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#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];
|
||||
int running;
|
||||
CURLM *m = NULL;
|
||||
int i;
|
||||
char target_url[256];
|
||||
int handles_added = 0;
|
||||
|
||||
for(i=0; i < NUM_HANDLES; i++)
|
||||
curl[i] = NULL;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
multi_init(m);
|
||||
|
||||
/* get NUM_HANDLES easy handles */
|
||||
for(i=0; i < NUM_HANDLES; i++) {
|
||||
/* get an easy handle */
|
||||
easy_init(curl[i]);
|
||||
/* specify target */
|
||||
snprintf(target_url, sizeof(target_url), "%s%04i", URL, 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);
|
||||
}
|
||||
|
||||
/* Add the first handle to multi. We do this to let libcurl detect
|
||||
that the server can do pipelining. The rest of the handles will be
|
||||
added later. */
|
||||
multi_add_handle(m, curl[handles_added++]);
|
||||
|
||||
multi_setopt(m, CURLMOPT_PIPELINING, 1L);
|
||||
|
||||
fprintf(stderr, "Start at URL 0\n");
|
||||
|
||||
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) {
|
||||
if(handles_added >= NUM_HANDLES)
|
||||
break; /* done */
|
||||
|
||||
/* Add the rest of the handles now that the first handle has completed
|
||||
its request. */
|
||||
while(handles_added < NUM_HANDLES)
|
||||
multi_add_handle(m, curl[handles_added++]);
|
||||
}
|
||||
|
||||
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 PB */
|
||||
|
||||
for(i=0; i < NUM_HANDLES; i++) {
|
||||
curl_multi_remove_handle(m, curl[i]);
|
||||
curl_easy_cleanup(curl[i]);
|
||||
}
|
||||
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
112
3rd-party/curl-7.52.1/tests/libtest/lib533.c
vendored
Normal file
112
3rd-party/curl-7.52.1/tests/libtest/lib533.c
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* used for test case 533, 534 and 535 */
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res = 0;
|
||||
CURL *curl = NULL;
|
||||
int running;
|
||||
CURLM *m = NULL;
|
||||
int current=0;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
easy_init(curl);
|
||||
|
||||
easy_setopt(curl, CURLOPT_URL, URL);
|
||||
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||
|
||||
multi_init(m);
|
||||
|
||||
multi_add_handle(m, curl);
|
||||
|
||||
fprintf(stderr, "Start at URL 0\n");
|
||||
|
||||
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) {
|
||||
if(!current++) {
|
||||
fprintf(stderr, "Advancing to URL 1\n");
|
||||
/* remove the handle we use */
|
||||
curl_multi_remove_handle(m, curl);
|
||||
|
||||
/* make us re-use the same handle all the time, and try resetting
|
||||
the handle first too */
|
||||
curl_easy_reset(curl);
|
||||
easy_setopt(curl, CURLOPT_URL, libtest_arg2);
|
||||
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||
|
||||
/* re-add it */
|
||||
multi_add_handle(m, curl);
|
||||
}
|
||||
else
|
||||
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:
|
||||
|
||||
/* undocumented cleanup sequence - type UB */
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
142
3rd-party/curl-7.52.1/tests/libtest/lib536.c
vendored
Normal file
142
3rd-party/curl-7.52.1/tests/libtest/lib536.c
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
static int perform(CURLM *multi)
|
||||
{
|
||||
int handles;
|
||||
fd_set fdread, fdwrite, fdexcep;
|
||||
int res = 0;
|
||||
|
||||
for(;;) {
|
||||
struct timeval interval;
|
||||
int maxfd = -99;
|
||||
|
||||
interval.tv_sec = 0;
|
||||
interval.tv_usec = 100000L; /* 100 ms */
|
||||
|
||||
res_multi_perform(multi, &handles);
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
res_test_timedout();
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
if(!handles)
|
||||
break; /* done */
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
res_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
|
||||
|
||||
res_select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
res_test_timedout();
|
||||
if(res)
|
||||
return res;
|
||||
}
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLM *multi = NULL;
|
||||
CURL *easy = NULL;
|
||||
int res = 0;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
multi_init(multi);
|
||||
|
||||
easy_init(easy);
|
||||
|
||||
multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
|
||||
|
||||
easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
|
||||
easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
|
||||
easy_setopt(easy, CURLOPT_URL, URL);
|
||||
|
||||
res_multi_add_handle(multi, easy);
|
||||
if(res) {
|
||||
printf("curl_multi_add_handle() 1 failed\n");
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
res = perform(multi);
|
||||
if(res) {
|
||||
printf("retrieve 1 failed\n");
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
curl_multi_remove_handle(multi, easy);
|
||||
|
||||
curl_easy_reset(easy);
|
||||
|
||||
easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
|
||||
easy_setopt(easy, CURLOPT_URL, libtest_arg2);
|
||||
|
||||
res_multi_add_handle(multi, easy);
|
||||
if(res) {
|
||||
printf("curl_multi_add_handle() 2 failed\n");
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
res = perform(multi);
|
||||
if(res) {
|
||||
printf("retrieve 2 failed\n");
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
curl_multi_remove_handle(multi, easy);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* undocumented cleanup sequence - type UB */
|
||||
|
||||
curl_easy_cleanup(easy);
|
||||
curl_multi_cleanup(multi);
|
||||
curl_global_cleanup();
|
||||
|
||||
printf("Finished!\n");
|
||||
|
||||
return res;
|
||||
}
|
525
3rd-party/curl-7.52.1/tests/libtest/lib537.c
vendored
Normal file
525
3rd-party/curl-7.52.1/tests/libtest/lib537.c
vendored
Normal file
@@ -0,0 +1,525 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#if !defined(HAVE_POLL_FINE) && \
|
||||
!defined(USE_WINSOCK) && \
|
||||
!defined(TPF) && \
|
||||
!defined(FD_SETSIZE)
|
||||
#error "this test requires FD_SETSIZE"
|
||||
#endif
|
||||
|
||||
#define SAFETY_MARGIN (11)
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(MSDOS)
|
||||
#define DEV_NULL "NUL"
|
||||
#else
|
||||
#define DEV_NULL "/dev/null"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
|
||||
|
||||
static int *fd = NULL;
|
||||
static struct rlimit num_open;
|
||||
static char msgbuff[256];
|
||||
|
||||
static void store_errmsg(const char *msg, int err)
|
||||
{
|
||||
if(!err)
|
||||
snprintf(msgbuff, sizeof(msgbuff), "%s", msg);
|
||||
else
|
||||
snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, err,
|
||||
strerror(err));
|
||||
}
|
||||
|
||||
static void close_file_descriptors(void)
|
||||
{
|
||||
for(num_open.rlim_cur = 0;
|
||||
num_open.rlim_cur < num_open.rlim_max;
|
||||
num_open.rlim_cur++)
|
||||
if(fd[num_open.rlim_cur] > 0)
|
||||
close(fd[num_open.rlim_cur]);
|
||||
free(fd);
|
||||
fd = NULL;
|
||||
}
|
||||
|
||||
static int fopen_works(void)
|
||||
{
|
||||
FILE *fpa[3];
|
||||
int i;
|
||||
int ret = 1;
|
||||
|
||||
for(i = 0; i < 3; i++) {
|
||||
fpa[i] = NULL;
|
||||
}
|
||||
for(i = 0; i < 3; i++) {
|
||||
fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
|
||||
if(fpa[i] == NULL) {
|
||||
store_errmsg("fopen failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < 3; i++) {
|
||||
if(fpa[i] != NULL)
|
||||
fclose(fpa[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rlimit(int keep_open)
|
||||
{
|
||||
int *tmpfd;
|
||||
int nitems, i;
|
||||
int *memchunk = NULL;
|
||||
char *fmt;
|
||||
struct rlimit rl;
|
||||
char strbuff[256];
|
||||
char strbuff1[81];
|
||||
char fmt_u[] = "%u";
|
||||
char fmt_lu[] = "%lu";
|
||||
#ifdef HAVE_LONGLONG
|
||||
char fmt_llu[] = "%llu";
|
||||
|
||||
if(sizeof(rl.rlim_max) > sizeof(long))
|
||||
fmt = fmt_llu;
|
||||
else
|
||||
#endif
|
||||
fmt = (sizeof(rl.rlim_max) < sizeof(long))?fmt_u:fmt_lu;
|
||||
|
||||
/* get initial open file limits */
|
||||
|
||||
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
store_errmsg("getrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* show initial open file limits */
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_cur == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur);
|
||||
fprintf(stderr, "initial soft limit: %s\n", strbuff);
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_max == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max);
|
||||
fprintf(stderr, "initial hard limit: %s\n", strbuff);
|
||||
|
||||
/*
|
||||
* if soft limit and hard limit are different we ask the
|
||||
* system to raise soft limit all the way up to the hard
|
||||
* limit. Due to some other system limit the soft limit
|
||||
* might not be raised up to the hard limit. So from this
|
||||
* point the resulting soft limit is our limit. Trying to
|
||||
* open more than soft limit file descriptors will fail.
|
||||
*/
|
||||
|
||||
if(rl.rlim_cur != rl.rlim_max) {
|
||||
|
||||
#ifdef OPEN_MAX
|
||||
if((rl.rlim_cur > 0) &&
|
||||
(rl.rlim_cur < OPEN_MAX)) {
|
||||
fprintf(stderr, "raising soft limit up to OPEN_MAX\n");
|
||||
rl.rlim_cur = OPEN_MAX;
|
||||
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
/* on failure don't abort just issue a warning */
|
||||
store_errmsg("setrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
msgbuff[0] = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "raising soft limit up to hard limit\n");
|
||||
rl.rlim_cur = rl.rlim_max;
|
||||
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
/* on failure don't abort just issue a warning */
|
||||
store_errmsg("setrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
msgbuff[0] = '\0';
|
||||
}
|
||||
|
||||
/* get current open file limits */
|
||||
|
||||
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
|
||||
store_errmsg("getrlimit() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* show current open file limits */
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_cur == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur);
|
||||
fprintf(stderr, "current soft limit: %s\n", strbuff);
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if(rl.rlim_max == RLIM_INFINITY)
|
||||
strcpy(strbuff, "INFINITY");
|
||||
else
|
||||
#endif
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max);
|
||||
fprintf(stderr, "current hard limit: %s\n", strbuff);
|
||||
|
||||
} /* (rl.rlim_cur != rl.rlim_max) */
|
||||
|
||||
/*
|
||||
* test 537 is all about testing libcurl functionality
|
||||
* when the system has nearly exhausted the number of
|
||||
* available file descriptors. Test 537 will try to run
|
||||
* with a very small number of file descriptors available.
|
||||
* This implies that any file descriptor which is open
|
||||
* when the test runs will have a number in the high range
|
||||
* of whatever the system supports.
|
||||
*/
|
||||
|
||||
/*
|
||||
* reserve a chunk of memory before opening file descriptors to
|
||||
* avoid a low memory condition once the file descriptors are
|
||||
* open. System conditions that could make the test fail should
|
||||
* be addressed in the precheck phase. This chunk of memory shall
|
||||
* be always free()ed before exiting the rlimit() function so
|
||||
* that it becomes available to the test.
|
||||
*/
|
||||
|
||||
for(nitems = i = 1; nitems <= i; i *= 2)
|
||||
nitems = i;
|
||||
if(nitems > 0x7fff)
|
||||
nitems = 0x40000;
|
||||
do {
|
||||
num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems;
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
|
||||
memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
|
||||
if(!memchunk) {
|
||||
fprintf(stderr, "memchunk, malloc() failed\n");
|
||||
nitems /= 2;
|
||||
}
|
||||
} while(nitems && !memchunk);
|
||||
if(!memchunk) {
|
||||
store_errmsg("memchunk, malloc() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
return -4;
|
||||
}
|
||||
|
||||
/* initialize it to fight lazy allocation */
|
||||
|
||||
fprintf(stderr, "initializing memchunk array\n");
|
||||
|
||||
for(i = 0; i < nitems; i++)
|
||||
memchunk[i] = -1;
|
||||
|
||||
/* set the number of file descriptors we will try to open */
|
||||
|
||||
#ifdef RLIM_INFINITY
|
||||
if((rl.rlim_cur > 0) && (rl.rlim_cur != RLIM_INFINITY)) {
|
||||
#else
|
||||
if(rl.rlim_cur > 0) {
|
||||
#endif
|
||||
/* soft limit minus SAFETY_MARGIN */
|
||||
num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN;
|
||||
}
|
||||
else {
|
||||
/* a huge number of file descriptors */
|
||||
for(nitems = i = 1; nitems <= i; i *= 2)
|
||||
nitems = i;
|
||||
if(nitems > 0x7fff)
|
||||
nitems = 0x40000;
|
||||
num_open.rlim_max = nitems;
|
||||
}
|
||||
|
||||
/* verify that we won't overflow size_t in malloc() */
|
||||
|
||||
if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) {
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max);
|
||||
snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s "
|
||||
"file descriptors, would overflow size_t", strbuff1);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
free(memchunk);
|
||||
return -5;
|
||||
}
|
||||
|
||||
/* allocate array for file descriptors */
|
||||
|
||||
do {
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "allocating array for %s file descriptors\n", strbuff);
|
||||
fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max));
|
||||
if(!fd) {
|
||||
fprintf(stderr, "fd, malloc() failed\n");
|
||||
num_open.rlim_max /= 2;
|
||||
}
|
||||
} while(num_open.rlim_max && !fd);
|
||||
if(!fd) {
|
||||
store_errmsg("fd, malloc() failed", ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
free(memchunk);
|
||||
return -6;
|
||||
}
|
||||
|
||||
/* initialize it to fight lazy allocation */
|
||||
|
||||
fprintf(stderr, "initializing fd array\n");
|
||||
|
||||
for(num_open.rlim_cur = 0;
|
||||
num_open.rlim_cur < num_open.rlim_max;
|
||||
num_open.rlim_cur++)
|
||||
fd[num_open.rlim_cur] = -1;
|
||||
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "trying to open %s file descriptors\n", strbuff);
|
||||
|
||||
/* open a dummy descriptor */
|
||||
|
||||
fd[0] = open(DEV_NULL, O_RDONLY);
|
||||
if(fd[0] < 0) {
|
||||
snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
|
||||
store_errmsg(strbuff, ERRNO);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
free(fd);
|
||||
fd = NULL;
|
||||
free(memchunk);
|
||||
return -7;
|
||||
}
|
||||
|
||||
/* create a bunch of file descriptors */
|
||||
|
||||
for(num_open.rlim_cur = 1;
|
||||
num_open.rlim_cur < num_open.rlim_max;
|
||||
num_open.rlim_cur++) {
|
||||
|
||||
fd[num_open.rlim_cur] = dup(fd[0]);
|
||||
|
||||
if(fd[num_open.rlim_cur] < 0) {
|
||||
|
||||
fd[num_open.rlim_cur] = -1;
|
||||
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
|
||||
snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1);
|
||||
fprintf(stderr, "%s\n", strbuff);
|
||||
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
|
||||
snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s",
|
||||
strbuff1);
|
||||
fprintf(stderr, "%s\n", strbuff);
|
||||
|
||||
num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN;
|
||||
|
||||
num_open.rlim_cur -= num_open.rlim_max;
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
|
||||
snprintf(strbuff, sizeof(strbuff), "closing %s file descriptors",
|
||||
strbuff1);
|
||||
fprintf(stderr, "%s\n", strbuff);
|
||||
|
||||
for(num_open.rlim_cur = num_open.rlim_max;
|
||||
fd[num_open.rlim_cur] >= 0;
|
||||
num_open.rlim_cur++) {
|
||||
close(fd[num_open.rlim_cur]);
|
||||
fd[num_open.rlim_cur] = -1;
|
||||
}
|
||||
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "shrinking array for %s file descriptors\n", strbuff);
|
||||
|
||||
/* we don't care if we can't shrink it */
|
||||
|
||||
tmpfd = realloc(fd, sizeof(*fd) * (size_t)(num_open.rlim_max));
|
||||
if(tmpfd) {
|
||||
fd = tmpfd;
|
||||
tmpfd = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
|
||||
fprintf(stderr, "%s file descriptors open\n", strbuff);
|
||||
|
||||
#if !defined(HAVE_POLL_FINE) && \
|
||||
!defined(USE_WINSOCK) && \
|
||||
!defined(TPF)
|
||||
|
||||
/*
|
||||
* when using select() instead of poll() we cannot test
|
||||
* libcurl functionality with a socket number equal or
|
||||
* greater than FD_SETSIZE. In any case, macro VERIFY_SOCK
|
||||
* in lib/select.c enforces this check and protects libcurl
|
||||
* from a possible crash. The effect of this protection
|
||||
* is that test 537 will always fail, since the actual
|
||||
* call to select() never takes place. We skip test 537
|
||||
* with an indication that select limit would be exceeded.
|
||||
*/
|
||||
|
||||
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
|
||||
if(num_open.rlim_max > num_open.rlim_cur) {
|
||||
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
|
||||
FD_SETSIZE);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
close_file_descriptors();
|
||||
free(memchunk);
|
||||
return -8;
|
||||
}
|
||||
|
||||
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
|
||||
for(rl.rlim_cur = 0;
|
||||
rl.rlim_cur < num_open.rlim_max;
|
||||
rl.rlim_cur++) {
|
||||
if((fd[rl.rlim_cur] > 0) &&
|
||||
((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) {
|
||||
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
|
||||
FD_SETSIZE);
|
||||
store_errmsg(strbuff, 0);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
close_file_descriptors();
|
||||
free(memchunk);
|
||||
return -9;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* using a FD_SETSIZE bound select() */
|
||||
|
||||
/*
|
||||
* Old or 'backwards compatible' implementations of stdio do not allow
|
||||
* handling of streams with an underlying file descriptor number greater
|
||||
* than 255, even when allowing high numbered file descriptors for sockets.
|
||||
* At this point we have a big number of file descriptors which have been
|
||||
* opened using dup(), so lets test the stdio implementation and discover
|
||||
* if it is capable of fopen()ing some additional files.
|
||||
*/
|
||||
|
||||
if(!fopen_works()) {
|
||||
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max);
|
||||
snprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open",
|
||||
strbuff1);
|
||||
fprintf(stderr, "%s\n", msgbuff);
|
||||
snprintf(strbuff, sizeof(strbuff), "fopen fails with lots of fds open");
|
||||
store_errmsg(strbuff, 0);
|
||||
close_file_descriptors();
|
||||
free(memchunk);
|
||||
return -10;
|
||||
}
|
||||
|
||||
/* free the chunk of memory we were reserving so that it
|
||||
becomes becomes available to the test */
|
||||
|
||||
free(memchunk);
|
||||
|
||||
/* close file descriptors unless instructed to keep them */
|
||||
|
||||
if(!keep_open) {
|
||||
close_file_descriptors();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
|
||||
if(!strcmp(URL, "check")) {
|
||||
/* used by the test script to ask if we can run this test or not */
|
||||
if(rlimit(FALSE)) {
|
||||
fprintf(stdout, "rlimit problem: %s\n", msgbuff);
|
||||
return 1;
|
||||
}
|
||||
return 0; /* sure, run this! */
|
||||
}
|
||||
|
||||
if(rlimit(TRUE)) {
|
||||
/* failure */
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
/* run the test with the bunch of open file descriptors
|
||||
and close them all once the test is over */
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
close_file_descriptors();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
close_file_descriptors();
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
close_file_descriptors();
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
#else /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
(void)URL;
|
||||
printf("system lacks necessary system function(s)");
|
||||
return 1; /* skip test */
|
||||
}
|
||||
|
||||
#endif /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
|
91
3rd-party/curl-7.52.1/tests/libtest/lib539.c
vendored
Normal file
91
3rd-party/curl-7.52.1/tests/libtest/lib539.c
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
char *newURL = NULL;
|
||||
struct curl_slist *slist = 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Begin with curl set to use a single CWD to the URL's directory.
|
||||
*/
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/*
|
||||
* Change the FTP_FILEMETHOD option to use full paths rather than a CWD
|
||||
* command. Alter the URL's path a bit, appending a "./". Use an innocuous
|
||||
* QUOTE command, after which curl will CWD to ftp_conn->entrypath and then
|
||||
* (on the next call to ftp_statemach_act) find a non-zero ftpconn->dirdepth
|
||||
* even though no directories are stored in the ftpconn->dirs array (after a
|
||||
* call to freedirs).
|
||||
*/
|
||||
newURL = aprintf("%s./", URL);
|
||||
if(newURL == NULL) {
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
slist = curl_slist_append(NULL, "SYST");
|
||||
if(slist == NULL) {
|
||||
free(newURL);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, newURL);
|
||||
test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
|
||||
test_setopt(curl, CURLOPT_QUOTE, slist);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(slist);
|
||||
free(newURL);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
248
3rd-party/curl-7.52.1/tests/libtest/lib540.c
vendored
Normal file
248
3rd-party/curl-7.52.1/tests/libtest/lib540.c
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* This is the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl
|
||||
* mailing list on 10 Jul 2007, converted to a test case.
|
||||
*
|
||||
* argv1 = URL
|
||||
* argv2 = proxy
|
||||
* argv3 = proxyuser:password
|
||||
* argv4 = host name to use for the custom Host: header
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
#define PROXY libtest_arg2
|
||||
#define PROXYUSERPWD libtest_arg3
|
||||
#define HOST test_argv[4]
|
||||
|
||||
#define NUM_HANDLES 2
|
||||
|
||||
CURL *eh[NUM_HANDLES];
|
||||
|
||||
static int init(int num, CURLM *cm, const char *url, const char *userpwd,
|
||||
struct curl_slist *headers)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
res_easy_init(eh[num]);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_easy_setopt(eh[num], CURLOPT_URL, url);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_easy_setopt(eh[num], CURLOPT_PROXY, PROXY);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_easy_setopt(eh[num], CURLOPT_PROXYUSERPWD, userpwd);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_easy_setopt(eh[num], CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_easy_setopt(eh[num], CURLOPT_VERBOSE, 1L);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_easy_setopt(eh[num], CURLOPT_HEADER, 1L);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_easy_setopt(eh[num], CURLOPT_HTTPHEADER, headers); /* custom Host: */
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
res_multi_add_handle(cm, eh[num]);
|
||||
if(res)
|
||||
goto init_failed;
|
||||
|
||||
return 0; /* success */
|
||||
|
||||
init_failed:
|
||||
|
||||
curl_easy_cleanup(eh[num]);
|
||||
eh[num] = NULL;
|
||||
|
||||
return res; /* failure */
|
||||
}
|
||||
|
||||
static int loop(int num, CURLM *cm, const char *url, const char *userpwd,
|
||||
struct curl_slist *headers)
|
||||
{
|
||||
CURLMsg *msg;
|
||||
long L;
|
||||
int Q, U = -1;
|
||||
fd_set R, W, E;
|
||||
struct timeval T;
|
||||
int res = 0;
|
||||
|
||||
res = init(num, cm, url, userpwd, headers);
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
while(U) {
|
||||
|
||||
int M = -99;
|
||||
|
||||
res_multi_perform(cm, &U);
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
res_test_timedout();
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
if(U) {
|
||||
FD_ZERO(&R);
|
||||
FD_ZERO(&W);
|
||||
FD_ZERO(&E);
|
||||
|
||||
res_multi_fdset(cm, &R, &W, &E, &M);
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
/* At this point, M is guaranteed to be greater or equal than -1. */
|
||||
|
||||
res_multi_timeout(cm, &L);
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
/* At this point, L is guaranteed to be greater or equal than -1. */
|
||||
|
||||
if(L != -1) {
|
||||
int itimeout = (L > (long)INT_MAX) ? INT_MAX : (int)L;
|
||||
T.tv_sec = itimeout/1000;
|
||||
T.tv_usec = (itimeout%1000)*1000;
|
||||
}
|
||||
else {
|
||||
T.tv_sec = 5;
|
||||
T.tv_usec = 0;
|
||||
}
|
||||
|
||||
res_select_test(M+1, &R, &W, &E, &T);
|
||||
if(res)
|
||||
return res;
|
||||
}
|
||||
|
||||
while((msg = curl_multi_info_read(cm, &Q)) != NULL) {
|
||||
if(msg->msg == CURLMSG_DONE) {
|
||||
int i;
|
||||
CURL *e = msg->easy_handle;
|
||||
fprintf(stderr, "R: %d - %s\n", (int)msg->data.result,
|
||||
curl_easy_strerror(msg->data.result));
|
||||
curl_multi_remove_handle(cm, e);
|
||||
curl_easy_cleanup(e);
|
||||
for(i=0; i < NUM_HANDLES; i++) {
|
||||
if(eh[i] == e) {
|
||||
eh[i] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg);
|
||||
}
|
||||
|
||||
res_test_timedout();
|
||||
if(res)
|
||||
return res;
|
||||
}
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLM *cm = NULL;
|
||||
struct curl_slist *headers = NULL;
|
||||
char buffer[246]; /* naively fixed-size */
|
||||
int res = 0;
|
||||
int i;
|
||||
|
||||
for(i=0; i < NUM_HANDLES; i++)
|
||||
eh[i] = NULL;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
if(test_argc < 4)
|
||||
return 99;
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "Host: %s", HOST);
|
||||
|
||||
/* now add a custom Host: header */
|
||||
headers = curl_slist_append(headers, buffer);
|
||||
if(!headers) {
|
||||
fprintf(stderr, "curl_slist_append() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
res_global_init(CURL_GLOBAL_ALL);
|
||||
if(res) {
|
||||
curl_slist_free_all(headers);
|
||||
return res;
|
||||
}
|
||||
|
||||
res_multi_init(cm);
|
||||
if(res) {
|
||||
curl_global_cleanup();
|
||||
curl_slist_free_all(headers);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = loop(0, cm, URL, PROXYUSERPWD, headers);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
fprintf(stderr, "lib540: now we do the request again\n");
|
||||
|
||||
res = loop(1, cm, URL, PROXYUSERPWD, headers);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* proper cleanup sequence - type PB */
|
||||
|
||||
for(i=0; i < NUM_HANDLES; i++) {
|
||||
curl_multi_remove_handle(cm, eh[i]);
|
||||
curl_easy_cleanup(eh[i]);
|
||||
}
|
||||
|
||||
curl_multi_cleanup(cm);
|
||||
curl_global_cleanup();
|
||||
|
||||
curl_slist_free_all(headers);
|
||||
|
||||
return res;
|
||||
}
|
118
3rd-party/curl-7.52.1/tests/libtest/lib541.c
vendored
Normal file
118
3rd-party/curl-7.52.1/tests/libtest/lib541.c
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Two FTP uploads, the second with no content sent.
|
||||
*/
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
FILE *hd_src;
|
||||
int hd;
|
||||
struct_stat file_info;
|
||||
int error;
|
||||
|
||||
if(!libtest_arg2) {
|
||||
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
||||
return TEST_ERR_USAGE;
|
||||
}
|
||||
|
||||
hd_src = fopen(libtest_arg2, "rb");
|
||||
if(NULL == hd_src) {
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fopen failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
|
||||
return -2; /* 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 */
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fstat() failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
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;
|
||||
}
|
||||
|
||||
/* enable uploading */
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* enable verbose */
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* specify target */
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* now specify which file to upload */
|
||||
test_setopt(curl, CURLOPT_READDATA, hd_src);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* and now upload the exact same again, but without rewinding so it already
|
||||
is at end of file */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* close the local file */
|
||||
fclose(hd_src);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
73
3rd-party/curl-7.52.1/tests/libtest/lib542.c
vendored
Normal file
73
3rd-party/curl-7.52.1/tests/libtest/lib542.c
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* FTP get with NOBODY but no HEADER
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* get a curl handle */
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
/* enable verbose */
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* enable NOBODY */
|
||||
test_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
|
||||
/* disable HEADER */
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
|
||||
/* specify target */
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
58
3rd-party/curl-7.52.1/tests/libtest/lib543.c
vendored
Normal file
58
3rd-party/curl-7.52.1/tests/libtest/lib543.c
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* Based on Alex Fishman's bug report on September 30, 2007 */
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
unsigned char a[] = {0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
|
||||
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
|
||||
0x1d, 0x57, 0xe1};
|
||||
|
||||
CURL *easy;
|
||||
int asize;
|
||||
char *s;
|
||||
(void)URL;
|
||||
|
||||
easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
asize = (int)sizeof(a);
|
||||
|
||||
s = curl_easy_escape(easy, (char *)a, asize);
|
||||
|
||||
if(s)
|
||||
printf("%s\n", s);
|
||||
|
||||
if(s)
|
||||
curl_free(s);
|
||||
|
||||
curl_easy_cleanup(easy);
|
||||
|
||||
return 0;
|
||||
}
|
92
3rd-party/curl-7.52.1/tests/libtest/lib544.c
vendored
Normal file
92
3rd-party/curl-7.52.1/tests/libtest/lib544.c
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static char teststring[] =
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* ASCII representation with escape sequences for non-ASCII platforms */
|
||||
"\x54\x68\x69\x73\x00\x20\x69\x73\x20\x74\x65\x73\x74\x20\x62\x69\x6e\x61"
|
||||
"\x72\x79\x20\x64\x61\x74\x61\x20\x77\x69\x74\x68\x20\x61\x6e\x20\x65\x6d"
|
||||
"\x62\x65\x64\x64\x65\x64\x20\x4e\x55\x4c\x20\x62\x79\x74\x65\x0a";
|
||||
#else
|
||||
{ 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ',
|
||||
'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ',
|
||||
'w', 'i', 't', 'h', ' ', 'a', 'n', ' ',
|
||||
'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'};
|
||||
#endif
|
||||
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
||||
#ifdef LIB545
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring);
|
||||
#endif
|
||||
|
||||
test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
|
||||
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Update the original data to detect non-copy. */
|
||||
strcpy(teststring, "FAIL");
|
||||
|
||||
#ifdef LIB545
|
||||
{
|
||||
CURL *handle2;
|
||||
handle2 = curl_easy_duphandle(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
curl = handle2;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now, this is a POST request with binary 0 embedded in POST data. */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
131
3rd-party/curl-7.52.1/tests/libtest/lib547.c
vendored
Normal file
131
3rd-party/curl-7.52.1/tests/libtest/lib547.c
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* argv1 = URL
|
||||
* argv2 = proxy
|
||||
* argv3 = proxyuser:password
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* ASCII representation with escape sequences for non-ASCII platforms */
|
||||
# define UPLOADTHIS "\x74\x68\x69\x73\x20\x69\x73\x20\x74\x68\x65\x20\x62" \
|
||||
"\x6c\x75\x72\x62\x20\x77\x65\x20\x77\x61\x6e\x74\x20" \
|
||||
"\x74\x6f\x20\x75\x70\x6c\x6f\x61\x64\x0a"
|
||||
#else
|
||||
# define UPLOADTHIS "this is the blurb we want to upload\n"
|
||||
#endif
|
||||
|
||||
#ifndef LIB548
|
||||
static size_t readcallback(void *ptr,
|
||||
size_t size,
|
||||
size_t nmemb,
|
||||
void *clientp)
|
||||
{
|
||||
int *counter = (int *)clientp;
|
||||
|
||||
if(*counter) {
|
||||
/* only do this once and then require a clearing of this */
|
||||
fprintf(stderr, "READ ALREADY DONE!\n");
|
||||
return 0;
|
||||
}
|
||||
(*counter)++; /* bump */
|
||||
|
||||
if(size * nmemb > strlen(UPLOADTHIS)) {
|
||||
fprintf(stderr, "READ!\n");
|
||||
strcpy(ptr, UPLOADTHIS);
|
||||
return strlen(UPLOADTHIS);
|
||||
}
|
||||
fprintf(stderr, "READ NOT FINE!\n");
|
||||
return 0;
|
||||
}
|
||||
static curlioerr ioctlcallback(CURL *handle,
|
||||
int cmd,
|
||||
void *clientp)
|
||||
{
|
||||
int *counter = (int *)clientp;
|
||||
(void)handle; /* unused */
|
||||
if(cmd == CURLIOCMD_RESTARTREAD) {
|
||||
fprintf(stderr, "REWIND!\n");
|
||||
*counter = 0; /* clear counter to make the read callback restart */
|
||||
}
|
||||
return CURLIOE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
#ifndef LIB548
|
||||
int counter=0;
|
||||
#endif
|
||||
|
||||
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_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
#ifdef LIB548
|
||||
/* set the data to POST with a mere pointer to a zero-terminated string */
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS);
|
||||
#else
|
||||
/* 547 style, which means reading the POST data from a callback */
|
||||
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
|
||||
test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
|
||||
test_setopt(curl, CURLOPT_READDATA, &counter);
|
||||
/* We CANNOT do the POST fine without setting the size (or choose
|
||||
chunked)! */
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS));
|
||||
#endif
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
|
||||
test_setopt(curl, CURLOPT_PROXYAUTH,
|
||||
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
66
3rd-party/curl-7.52.1/tests/libtest/lib549.c
vendored
Normal file
66
3rd-party/curl-7.52.1/tests/libtest/lib549.c
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* argv1 = URL
|
||||
* argv2 = proxy
|
||||
* argv3 = non-zero means ASCII transfer
|
||||
*/
|
||||
|
||||
#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_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if(libtest_arg3) {
|
||||
/* enable ascii/text mode */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
}
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
225
3rd-party/curl-7.52.1/tests/libtest/lib552.c
vendored
Normal file
225
3rd-party/curl-7.52.1/tests/libtest/lib552.c
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/* argv1 = URL
|
||||
* argv2 = proxy with embedded user+password
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
struct data {
|
||||
char trace_ascii; /* 1 or 0 */
|
||||
};
|
||||
|
||||
static
|
||||
void dump(const char *text,
|
||||
FILE *stream, unsigned char *ptr, size_t size,
|
||||
char nohex)
|
||||
{
|
||||
size_t i;
|
||||
size_t c;
|
||||
|
||||
unsigned int width=0x10;
|
||||
|
||||
if(nohex)
|
||||
/* without the hex output, we can fit more on screen */
|
||||
width = 0x40;
|
||||
|
||||
fprintf(stream, "%s, %d bytes (0x%x)\n", text, (int)size, (int)size);
|
||||
|
||||
for(i=0; i<size; i+= width) {
|
||||
|
||||
fprintf(stream, "%04x: ", (int)i);
|
||||
|
||||
if(!nohex) {
|
||||
/* hex not disabled, show it */
|
||||
for(c = 0; c < width; c++)
|
||||
if(i+c < size)
|
||||
fprintf(stream, "%02x ", ptr[i+c]);
|
||||
else
|
||||
fputs(" ", stream);
|
||||
}
|
||||
|
||||
for(c = 0; (c < width) && (i+c < size); c++) {
|
||||
/* check for 0D0A; if found, skip past and start a new line of output */
|
||||
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
|
||||
i+=(c+2-width);
|
||||
break;
|
||||
}
|
||||
fprintf(stream, "%c",
|
||||
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
|
||||
/* check again for 0D0A, to avoid an extra \n if it's at width */
|
||||
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
|
||||
i+=(c+3-width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fputc('\n', stream); /* newline */
|
||||
}
|
||||
fflush(stream);
|
||||
}
|
||||
|
||||
static
|
||||
int my_trace(CURL *handle, curl_infotype type,
|
||||
char *data, size_t size,
|
||||
void *userp)
|
||||
{
|
||||
struct data *config = (struct data *)userp;
|
||||
const char *text;
|
||||
(void)handle; /* prevent compiler warning */
|
||||
|
||||
switch(type) {
|
||||
case CURLINFO_TEXT:
|
||||
fprintf(stderr, "== Info: %s", (char *)data);
|
||||
default: /* in case a new one is introduced to shock us */
|
||||
return 0;
|
||||
|
||||
case CURLINFO_HEADER_OUT:
|
||||
text = "=> Send header";
|
||||
break;
|
||||
case CURLINFO_DATA_OUT:
|
||||
text = "=> Send data";
|
||||
break;
|
||||
case CURLINFO_SSL_DATA_OUT:
|
||||
text = "=> Send SSL data";
|
||||
break;
|
||||
case CURLINFO_HEADER_IN:
|
||||
text = "<= Recv header";
|
||||
break;
|
||||
case CURLINFO_DATA_IN:
|
||||
text = "<= Recv data";
|
||||
break;
|
||||
case CURLINFO_SSL_DATA_IN:
|
||||
text = "<= Recv SSL data";
|
||||
break;
|
||||
}
|
||||
|
||||
dump(text, stderr, (unsigned char *)data, size, config->trace_ascii);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static size_t current_offset = 0;
|
||||
static char databuf[70000]; /* MUST be more than 64k OR
|
||||
MAX_INITIAL_POST_SIZE */
|
||||
|
||||
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
size_t amount = nmemb * size; /* Total bytes curl wants */
|
||||
size_t available = sizeof(databuf) - current_offset; /* What we have to
|
||||
give */
|
||||
size_t given = amount < available ? amount : available; /* What is given */
|
||||
(void)stream;
|
||||
memcpy(ptr, databuf + current_offset, given);
|
||||
current_offset += given;
|
||||
return given;
|
||||
}
|
||||
|
||||
|
||||
static size_t write_callback(void *ptr, size_t size, size_t nmemb,
|
||||
void *stream)
|
||||
{
|
||||
int amount = curlx_uztosi(size * nmemb);
|
||||
printf("%.*s", amount, (char *)ptr);
|
||||
(void)stream;
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
|
||||
static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
|
||||
{
|
||||
(void)clientp;
|
||||
if(cmd == CURLIOCMD_RESTARTREAD) {
|
||||
printf("APPLICATION: recieved a CURLIOCMD_RESTARTREAD request\n");
|
||||
printf("APPLICATION: ** REWINDING! **\n");
|
||||
current_offset = 0;
|
||||
return CURLIOE_OK;
|
||||
}
|
||||
(void)handle;
|
||||
return CURLIOE_UNKNOWNCMD;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OUT_OF_MEMORY;
|
||||
struct data config;
|
||||
size_t i;
|
||||
static const char fill[] = "test data";
|
||||
|
||||
config.trace_ascii = 1; /* enable ascii tracing */
|
||||
|
||||
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_DEBUGFUNCTION, my_trace);
|
||||
test_setopt(curl, CURLOPT_DEBUGDATA, &config);
|
||||
/* the DEBUGFUNCTION has no effect until we enable VERBOSE */
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* setup repeated data string */
|
||||
for(i=0; i < sizeof(databuf); ++i)
|
||||
databuf[i] = fill[i % sizeof fill];
|
||||
|
||||
/* Post */
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* Setup read callback */
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf));
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* Write callback */
|
||||
test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
|
||||
/* Ioctl function */
|
||||
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
|
||||
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Accept any auth. But for this bug configure proxy with DIGEST, basic
|
||||
might work too, not NTLM */
|
||||
test_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
fprintf(stderr, "curl_easy_perform = %d\n", (int)res);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
return (int)res;
|
||||
}
|
115
3rd-party/curl-7.52.1/tests/libtest/lib553.c
vendored
Normal file
115
3rd-party/curl-7.52.1/tests/libtest/lib553.c
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* This test case and code is based on the bug recipe Joe Malicki provided for
|
||||
* bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release.
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
#define POSTLEN 40960
|
||||
|
||||
static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
static size_t total=POSTLEN;
|
||||
static char buf[1024];
|
||||
(void)stream;
|
||||
|
||||
memset(buf, 'A', sizeof(buf));
|
||||
|
||||
size *= nmemb;
|
||||
if(size > total)
|
||||
size = total;
|
||||
|
||||
if(size > sizeof(buf))
|
||||
size = sizeof(buf);
|
||||
|
||||
memcpy(ptr, buf, size);
|
||||
total -= size;
|
||||
return size;
|
||||
}
|
||||
|
||||
#define NUM_HEADERS 8
|
||||
#define SIZE_HEADERS 5000
|
||||
|
||||
static char buf[SIZE_HEADERS + 100];
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_FAILED_INIT;
|
||||
int i;
|
||||
struct curl_slist *headerlist=NULL, *hl;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
for(i = 0; i < NUM_HEADERS; i++) {
|
||||
int len = snprintf(buf, sizeof(buf), "Header%d: ", i);
|
||||
memset(&buf[len], 'A', SIZE_HEADERS);
|
||||
buf[len + SIZE_HEADERS]=0; /* zero terminate */
|
||||
hl = curl_slist_append(headerlist, buf);
|
||||
if(!hl)
|
||||
goto test_cleanup;
|
||||
headerlist = hl;
|
||||
}
|
||||
|
||||
hl = curl_slist_append(headerlist, "Expect: ");
|
||||
if(!hl)
|
||||
goto test_cleanup;
|
||||
headerlist = hl;
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
curl_slist_free_all(headerlist);
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
224
3rd-party/curl-7.52.1/tests/libtest/lib554.c
vendored
Normal file
224
3rd-party/curl-7.52.1/tests/libtest/lib554.c
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static char data[]=
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* ASCII representation with escape sequences for non-ASCII platforms */
|
||||
"\x74\x68\x69\x73\x20\x69\x73\x20\x77\x68\x61\x74\x20\x77\x65\x20\x70"
|
||||
"\x6f\x73\x74\x20\x74\x6f\x20\x74\x68\x65\x20\x73\x69\x6c\x6c\x79\x20"
|
||||
"\x77\x65\x62\x20\x73\x65\x72\x76\x65\x72\x0a";
|
||||
#else
|
||||
"this is what we post to the silly web server\n";
|
||||
#endif
|
||||
|
||||
struct WriteThis {
|
||||
char *readptr;
|
||||
size_t sizeleft;
|
||||
};
|
||||
|
||||
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
#ifdef LIB587
|
||||
(void)ptr;
|
||||
(void)size;
|
||||
(void)nmemb;
|
||||
(void)userp;
|
||||
return CURL_READFUNC_ABORT;
|
||||
#else
|
||||
|
||||
struct WriteThis *pooh = (struct WriteThis *)userp;
|
||||
|
||||
if(size*nmemb < 1)
|
||||
return 0;
|
||||
|
||||
if(pooh->sizeleft) {
|
||||
*(char *)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 */
|
||||
#endif
|
||||
}
|
||||
|
||||
static int once(char *URL, bool oldstyle)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res=CURLE_OK;
|
||||
CURLFORMcode formrc;
|
||||
|
||||
struct curl_httppost *formpost=NULL;
|
||||
struct curl_httppost *lastptr=NULL;
|
||||
struct WriteThis pooh;
|
||||
struct WriteThis pooh2;
|
||||
|
||||
pooh.readptr = data;
|
||||
pooh.sizeleft = strlen(data);
|
||||
|
||||
/* Fill in the file upload field */
|
||||
if(oldstyle) {
|
||||
formrc = curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "sendfile",
|
||||
CURLFORM_STREAM, &pooh,
|
||||
CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
|
||||
CURLFORM_FILENAME, "postit2.c",
|
||||
CURLFORM_END);
|
||||
}
|
||||
else {
|
||||
/* new style */
|
||||
formrc = curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "sendfile alternative",
|
||||
CURLFORM_STREAM, &pooh,
|
||||
CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
|
||||
CURLFORM_FILENAME, "file name 2",
|
||||
CURLFORM_END);
|
||||
}
|
||||
|
||||
if(formrc)
|
||||
printf("curl_formadd(1) = %d\n", (int)formrc);
|
||||
|
||||
/* Now add the same data with another name and make it not look like
|
||||
a file upload but still using the callback */
|
||||
|
||||
pooh2.readptr = data;
|
||||
pooh2.sizeleft = strlen(data);
|
||||
|
||||
/* Fill in the file upload field */
|
||||
formrc = curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "callbackdata",
|
||||
CURLFORM_STREAM, &pooh2,
|
||||
CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
|
||||
CURLFORM_END);
|
||||
|
||||
if(formrc)
|
||||
printf("curl_formadd(1) = %d\n", (int)formrc);
|
||||
|
||||
/* Fill in the filename field */
|
||||
formrc = curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "filename",
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* ASCII representation with escape
|
||||
sequences for non-ASCII platforms */
|
||||
CURLFORM_COPYCONTENTS,
|
||||
"\x70\x6f\x73\x74\x69\x74\x32\x2e\x63",
|
||||
#else
|
||||
CURLFORM_COPYCONTENTS, "postit2.c",
|
||||
#endif
|
||||
CURLFORM_END);
|
||||
|
||||
if(formrc)
|
||||
printf("curl_formadd(2) = %d\n", (int)formrc);
|
||||
|
||||
/* Fill in a submit field too */
|
||||
formrc = curl_formadd(&formpost,
|
||||
&lastptr,
|
||||
CURLFORM_COPYNAME, "submit",
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* ASCII representation with escape
|
||||
sequences for non-ASCII platforms */
|
||||
CURLFORM_COPYCONTENTS, "\x73\x65\x6e\x64",
|
||||
#else
|
||||
CURLFORM_COPYCONTENTS, "send",
|
||||
#endif
|
||||
CURLFORM_END);
|
||||
|
||||
if(formrc)
|
||||
printf("curl_formadd(3) = %d\n", (int)formrc);
|
||||
|
||||
formrc = curl_formadd(&formpost, &lastptr,
|
||||
CURLFORM_COPYNAME, "somename",
|
||||
CURLFORM_BUFFER, "somefile.txt",
|
||||
CURLFORM_BUFFERPTR, "blah blah",
|
||||
CURLFORM_BUFFERLENGTH, (long)9,
|
||||
CURLFORM_END);
|
||||
|
||||
if(formrc)
|
||||
printf("curl_formadd(4) = %d\n", (int)formrc);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_formfree(formpost);
|
||||
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);
|
||||
|
||||
/* send a multi-part formpost */
|
||||
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* now cleanup the formpost chain */
|
||||
curl_formfree(formpost);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
res = once(URL, TRUE); /* old */
|
||||
if(!res)
|
||||
res = once(URL, FALSE); /* new */
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
160
3rd-party/curl-7.52.1/tests/libtest/lib555.c
vendored
Normal file
160
3rd-party/curl-7.52.1/tests/libtest/lib555.c
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* This test case is supposed to be identical to 547 except that this uses the
|
||||
* multi interface and 547 is easy interface.
|
||||
*
|
||||
* argv1 = URL
|
||||
* argv2 = proxy
|
||||
* argv3 = proxyuser:password
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
#define UPLOADTHIS "this is the blurb we want to upload\n"
|
||||
|
||||
static size_t readcallback(void *ptr,
|
||||
size_t size,
|
||||
size_t nmemb,
|
||||
void *clientp)
|
||||
{
|
||||
int *counter = (int *)clientp;
|
||||
|
||||
if(*counter) {
|
||||
/* only do this once and then require a clearing of this */
|
||||
fprintf(stderr, "READ ALREADY DONE!\n");
|
||||
return 0;
|
||||
}
|
||||
(*counter)++; /* bump */
|
||||
|
||||
if(size * nmemb > strlen(UPLOADTHIS)) {
|
||||
fprintf(stderr, "READ!\n");
|
||||
strcpy(ptr, UPLOADTHIS);
|
||||
return strlen(UPLOADTHIS);
|
||||
}
|
||||
fprintf(stderr, "READ NOT FINE!\n");
|
||||
return 0;
|
||||
}
|
||||
static curlioerr ioctlcallback(CURL *handle,
|
||||
int cmd,
|
||||
void *clientp)
|
||||
{
|
||||
int *counter = (int *)clientp;
|
||||
(void)handle; /* unused */
|
||||
if(cmd == CURLIOCMD_RESTARTREAD) {
|
||||
fprintf(stderr, "REWIND!\n");
|
||||
*counter = 0; /* clear counter to make the read callback restart */
|
||||
}
|
||||
return CURLIOE_OK;
|
||||
}
|
||||
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res = 0;
|
||||
CURL *curl = NULL;
|
||||
int counter=0;
|
||||
CURLM *m = NULL;
|
||||
int running=1;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
easy_init(curl);
|
||||
|
||||
easy_setopt(curl, CURLOPT_URL, URL);
|
||||
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
/* read the POST data from a callback */
|
||||
easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
|
||||
easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
|
||||
easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
|
||||
easy_setopt(curl, CURLOPT_READDATA, &counter);
|
||||
/* We CANNOT do the POST fine without setting the size (or choose
|
||||
chunked)! */
|
||||
easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
|
||||
|
||||
easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII. */
|
||||
easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
|
||||
easy_setopt(curl, CURLOPT_PROXYAUTH,
|
||||
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
|
||||
|
||||
multi_init(m);
|
||||
|
||||
multi_add_handle(m, curl);
|
||||
|
||||
while(running) {
|
||||
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();
|
||||
|
||||
#ifdef TPF
|
||||
sleep(1); /* avoid ctl-10 dump */
|
||||
#endif
|
||||
|
||||
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, curl);
|
||||
curl_multi_cleanup(m);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
109
3rd-party/curl-7.52.1/tests/libtest/lib556.c
vendored
Normal file
109
3rd-party/curl-7.52.1/tests/libtest/lib556.c
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* For Windows, mainly (may be moved in a config file?) */
|
||||
#ifndef STDIN_FILENO
|
||||
#define STDIN_FILENO 0
|
||||
#endif
|
||||
#ifndef STDOUT_FILENO
|
||||
#define STDOUT_FILENO 1
|
||||
#endif
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
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_CONNECT_ONLY, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(!res) {
|
||||
/* we are connected, now get a HTTP document the raw way */
|
||||
const char *request =
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* ASCII representation with escape sequences for non-ASCII platforms */
|
||||
"\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e"
|
||||
"\x32\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a"
|
||||
"\x0d\x0a";
|
||||
#else
|
||||
"GET /556 HTTP/1.2\r\n"
|
||||
"Host: ninja\r\n\r\n";
|
||||
#endif
|
||||
size_t iolen;
|
||||
char buf[1024];
|
||||
|
||||
res = curl_easy_send(curl, request, strlen(request), &iolen);
|
||||
|
||||
if(!res) {
|
||||
/* we assume that sending always work */
|
||||
|
||||
do {
|
||||
/* busy-read like crazy */
|
||||
res = curl_easy_recv(curl, buf, sizeof(buf), &iolen);
|
||||
|
||||
#ifdef TPF
|
||||
sleep(1); /* avoid ctl-10 dump */
|
||||
#endif
|
||||
|
||||
if(iolen) {
|
||||
/* send received stuff to stdout */
|
||||
if(!write(STDOUT_FILENO, buf, iolen))
|
||||
break;
|
||||
}
|
||||
|
||||
} while((res == CURLE_OK && iolen != 0) || (res == CURLE_AGAIN));
|
||||
}
|
||||
|
||||
if(res != CURLE_OK || iolen != 0)
|
||||
return TEST_ERR_FAILURE;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
1683
3rd-party/curl-7.52.1/tests/libtest/lib557.c
vendored
Normal file
1683
3rd-party/curl-7.52.1/tests/libtest/lib557.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
53
3rd-party/curl-7.52.1/tests/libtest/lib558.c
vendored
Normal file
53
3rd-party/curl-7.52.1/tests/libtest/lib558.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
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;
|
||||
|
||||
(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;
|
||||
}
|
||||
|
||||
ptr = malloc(558);
|
||||
Curl_safefree(ptr);
|
||||
|
||||
asize = (int)sizeof(a);
|
||||
ptr = curl_easy_escape(NULL, (char *)a, asize);
|
||||
if(ptr)
|
||||
curl_free(ptr);
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
113
3rd-party/curl-7.52.1/tests/libtest/lib560.c
vendored
Normal file
113
3rd-party/curl-7.52.1/tests/libtest/lib560.c
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
/*
|
||||
* Simply download a HTTPS file!
|
||||
*
|
||||
* This test was added after the HTTPS-using-multi-interface with OpenSSL
|
||||
* regression of 7.19.1 to hopefully prevent this embarassing mistake from
|
||||
* appearing again... Unfortunately the bug wasn't triggered by this test,
|
||||
* which presumably is because the connect to a local server is too
|
||||
* fast/different compared to the real/distant servers we saw the bug happen
|
||||
* with.
|
||||
*/
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *http_handle = NULL;
|
||||
CURLM *multi_handle = NULL;
|
||||
int res = 0;
|
||||
|
||||
int still_running; /* keep number of running handles */
|
||||
|
||||
start_test_timing();
|
||||
|
||||
/*
|
||||
** curl_global_init called indirectly from curl_easy_init.
|
||||
*/
|
||||
|
||||
easy_init(http_handle);
|
||||
|
||||
/* set options */
|
||||
easy_setopt(http_handle, CURLOPT_URL, URL);
|
||||
easy_setopt(http_handle, CURLOPT_HEADER, 1L);
|
||||
easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
|
||||
/* init a multi stack */
|
||||
multi_init(multi_handle);
|
||||
|
||||
/* add the individual transfers */
|
||||
multi_add_handle(multi_handle, http_handle);
|
||||
|
||||
/* we start some action by calling perform right away */
|
||||
multi_perform(multi_handle, &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);
|
||||
|
||||
/* set a suitable timeout to play around with */
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
/* get file descriptors from the transfers */
|
||||
multi_fdset(multi_handle, &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();
|
||||
|
||||
/* timeout or readable/writable sockets */
|
||||
multi_perform(multi_handle, &still_running);
|
||||
|
||||
abort_on_test_timeout();
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* undocumented cleanup sequence - type UA */
|
||||
|
||||
curl_multi_cleanup(multi_handle);
|
||||
curl_easy_cleanup(http_handle);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
74
3rd-party/curl-7.52.1/tests/libtest/lib562.c
vendored
Normal file
74
3rd-party/curl-7.52.1/tests/libtest/lib562.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* From "KNOWN_BUGS" April 2009:
|
||||
|
||||
59. If the CURLOPT_PORT option is used on an FTP URL like
|
||||
"ftp://example.com/file;type=A" the ";type=A" is stripped off.
|
||||
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* get a curl handle */
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
/* enable verbose */
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* set port number */
|
||||
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
|
||||
|
||||
/* specify target */
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
93
3rd-party/curl-7.52.1/tests/libtest/lib564.c
vendored
Normal file
93
3rd-party/curl-7.52.1/tests/libtest/lib564.c
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res = 0;
|
||||
CURL *curl = NULL;
|
||||
int running;
|
||||
CURLM *m = NULL;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
easy_init(curl);
|
||||
|
||||
easy_setopt(curl, CURLOPT_URL, URL);
|
||||
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
easy_setopt(curl, CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4);
|
||||
|
||||
multi_init(m);
|
||||
|
||||
multi_add_handle(m, curl);
|
||||
|
||||
fprintf(stderr, "Start at URL 0\n");
|
||||
|
||||
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:
|
||||
|
||||
/* undocumented cleanup sequence - type UB */
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
68
3rd-party/curl-7.52.1/tests/libtest/lib566.c
vendored
Normal file
68
3rd-party/curl-7.52.1/tests/libtest/lib566.c
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
|
||||
double content_length = 3;
|
||||
|
||||
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);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if(!res) {
|
||||
FILE *moo;
|
||||
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
|
||||
&content_length);
|
||||
moo = fopen(libtest_arg2, "wb");
|
||||
if(moo) {
|
||||
fprintf(moo, "CL: %.0f\n", content_length);
|
||||
fclose(moo);
|
||||
}
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
70
3rd-party/curl-7.52.1/tests/libtest/lib567.c
vendored
Normal file
70
3rd-party/curl-7.52.1/tests/libtest/lib567.c
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/*
|
||||
* Test a simple OPTIONS request with a custom header
|
||||
*/
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
struct curl_slist *custom_headers=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;
|
||||
}
|
||||
|
||||
/* Dump data to stdout for protocol verification */
|
||||
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
test_setopt(curl, CURLOPT_USERAGENT, "test567");
|
||||
|
||||
custom_headers = curl_slist_append(custom_headers, "Test-Number: 567");
|
||||
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(custom_headers)
|
||||
curl_slist_free_all(custom_headers);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
178
3rd-party/curl-7.52.1/tests/libtest/lib568.c
vendored
Normal file
178
3rd-party/curl-7.52.1/tests/libtest/lib568.c
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* build request url */
|
||||
static char *suburl(const char *base, int i)
|
||||
{
|
||||
return curl_maprintf("%s%.4d", base, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test the Client->Server ANNOUNCE functionality (PUT style)
|
||||
*/
|
||||
int test(char *URL)
|
||||
{
|
||||
int res;
|
||||
CURL *curl;
|
||||
int sdp;
|
||||
FILE *sdpf = NULL;
|
||||
struct_stat file_info;
|
||||
char *stream_uri = NULL;
|
||||
int request=1;
|
||||
struct curl_slist *custom_headers=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_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
sdp = open("log/file568.txt", O_RDONLY);
|
||||
fstat(sdp, &file_info);
|
||||
close(sdp);
|
||||
|
||||
sdpf = fopen("log/file568.txt", "rb");
|
||||
if(sdpf == NULL) {
|
||||
fprintf(stderr, "can't open log/file568.txt\n");
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
|
||||
|
||||
test_setopt(curl, CURLOPT_READDATA, sdpf);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
|
||||
|
||||
/* Do the ANNOUNCE */
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 0L);
|
||||
fclose(sdpf);
|
||||
sdpf = NULL;
|
||||
|
||||
/* Make sure we can do a normal request now */
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
/* Now do a POST style one */
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
custom_headers = curl_slist_append(custom_headers,
|
||||
"Content-Type: posty goodness");
|
||||
if(!custom_headers) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS,
|
||||
"postyfield=postystuff&project=curl\n");
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
|
||||
test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
|
||||
curl_slist_free_all(custom_headers);
|
||||
custom_headers = NULL;
|
||||
|
||||
/* Make sure we can do a normal request now */
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(sdpf)
|
||||
fclose(sdpf);
|
||||
|
||||
free(stream_uri);
|
||||
|
||||
if(custom_headers)
|
||||
curl_slist_free_all(custom_headers);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
128
3rd-party/curl-7.52.1/tests/libtest/lib569.c
vendored
Normal file
128
3rd-party/curl-7.52.1/tests/libtest/lib569.c
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* build request url */
|
||||
static char *suburl(const char *base, int i)
|
||||
{
|
||||
return curl_maprintf("%s%.4d", base, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test Session ID capture
|
||||
*/
|
||||
int test(char *URL)
|
||||
{
|
||||
int res;
|
||||
CURL *curl;
|
||||
char *stream_uri = NULL;
|
||||
char *rtsp_session_id;
|
||||
int request=1;
|
||||
int i;
|
||||
FILE *idfile = NULL;
|
||||
|
||||
idfile = fopen(libtest_arg2, "wb");
|
||||
if(idfile == NULL) {
|
||||
fprintf(stderr, "couldn't open the Session ID File\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
fclose(idfile);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
fclose(idfile);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res != (int)CURLE_BAD_FUNCTION_ARGUMENT) {
|
||||
fprintf(stderr, "This should have failed. "
|
||||
"Cannot setup without a Transport: header");
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
/* Go through the various Session IDs */
|
||||
for(i = 0; i < 3; i++) {
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
|
||||
"Fake/NotReal/JustATest;foo=baz");
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id);
|
||||
fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
|
||||
rtsp_session_id = NULL;
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Clear for the next go-round */
|
||||
test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(idfile)
|
||||
fclose(idfile);
|
||||
|
||||
free(stream_uri);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
116
3rd-party/curl-7.52.1/tests/libtest/lib570.c
vendored
Normal file
116
3rd-party/curl-7.52.1/tests/libtest/lib570.c
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
/* build request url */
|
||||
static char *suburl(const char *base, int i)
|
||||
{
|
||||
return curl_maprintf("%s%.4d", base, i);
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res;
|
||||
CURL *curl;
|
||||
int request=1;
|
||||
char *stream_uri = 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_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res != (int)CURLE_RTSP_CSEQ_ERROR) {
|
||||
fprintf(stderr, "Failed to detect CSeq mismatch");
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999L);
|
||||
test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
|
||||
"RAW/RAW/UDP;unicast;client_port=3056-3057");
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res != CURLE_RTSP_SESSION_ERROR) {
|
||||
fprintf(stderr, "Failed to detect a Session ID mismatch");
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
free(stream_uri);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
215
3rd-party/curl-7.52.1/tests/libtest/lib571.c
vendored
Normal file
215
3rd-party/curl-7.52.1/tests/libtest/lib571.c
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))
|
||||
|
||||
#define RTP_PKT_LENGTH(p) ((((int)((unsigned char)((p)[2]))) << 8) | \
|
||||
((int)((unsigned char)((p)[3]))))
|
||||
|
||||
#define RTP_DATA_SIZE 12
|
||||
static const char *RTP_DATA = "$_1234\n\0asdf";
|
||||
|
||||
static int rtp_packet_count = 0;
|
||||
|
||||
static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
char *data = (char *)ptr;
|
||||
int channel = RTP_PKT_CHANNEL(data);
|
||||
int message_size;
|
||||
int coded_size = RTP_PKT_LENGTH(data);
|
||||
size_t failure = (size * nmemb) ? 0 : 1;
|
||||
int i;
|
||||
(void)stream;
|
||||
|
||||
message_size = curlx_uztosi(size * nmemb) - 4;
|
||||
|
||||
printf("RTP: message size %d, channel %d\n", message_size, channel);
|
||||
if(message_size != coded_size) {
|
||||
printf("RTP embedded size (%d) does not match the write size (%d).\n",
|
||||
coded_size, message_size);
|
||||
return failure;
|
||||
}
|
||||
|
||||
data += 4;
|
||||
for(i = 0; i < message_size; i+= RTP_DATA_SIZE) {
|
||||
if(message_size - i > RTP_DATA_SIZE) {
|
||||
if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) {
|
||||
printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i);
|
||||
return failure;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(memcmp(RTP_DATA, data + i, message_size - i) != 0) {
|
||||
printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n",
|
||||
message_size - i, data + i);
|
||||
return failure;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rtp_packet_count++;
|
||||
fprintf(stderr, "packet count is %d\n", rtp_packet_count);
|
||||
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
/* build request url */
|
||||
static char *suburl(const char *base, int i)
|
||||
{
|
||||
return curl_maprintf("%s%.4d", base, i);
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res;
|
||||
CURL *curl;
|
||||
char *stream_uri = NULL;
|
||||
int request=1;
|
||||
FILE *protofile = NULL;
|
||||
|
||||
protofile = fopen(libtest_arg2, "wb");
|
||||
if(protofile == NULL) {
|
||||
fprintf(stderr, "Couldn't open the protocol dump file\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
fclose(protofile);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
fclose(protofile);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
|
||||
test_setopt(curl, CURLOPT_TIMEOUT, 3L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, protofile);
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1");
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
/* This PLAY starts the interleave */
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
/* The DESCRIBE request will try to consume data after the Content */
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
fprintf(stderr, "PLAY COMPLETE\n");
|
||||
|
||||
/* Use Receive to get the rest of the data */
|
||||
while(!res && rtp_packet_count < 13) {
|
||||
fprintf(stderr, "LOOPY LOOP!\n");
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE);
|
||||
res = curl_easy_perform(curl);
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
free(stream_uri);
|
||||
|
||||
if(protofile)
|
||||
fclose(protofile);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
184
3rd-party/curl-7.52.1/tests/libtest/lib572.c
vendored
Normal file
184
3rd-party/curl-7.52.1/tests/libtest/lib572.c
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* build request url */
|
||||
static char *suburl(const char *base, int i)
|
||||
{
|
||||
return curl_maprintf("%s%.4d", base, i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test GET_PARAMETER: PUT, HEARTBEAT, and POST
|
||||
*/
|
||||
int test(char *URL)
|
||||
{
|
||||
int res;
|
||||
CURL *curl;
|
||||
int params;
|
||||
FILE *paramsf = NULL;
|
||||
struct_stat file_info;
|
||||
char *stream_uri = NULL;
|
||||
int request=1;
|
||||
struct curl_slist *custom_headers=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_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* SETUP */
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles");
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
/* PUT style GET_PARAMETERS */
|
||||
params = open("log/file572.txt", O_RDONLY);
|
||||
fstat(params, &file_info);
|
||||
close(params);
|
||||
|
||||
paramsf = fopen("log/file572.txt", "rb");
|
||||
if(paramsf == NULL) {
|
||||
fprintf(stderr, "can't open log/file572.txt\n");
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
|
||||
|
||||
test_setopt(curl, CURLOPT_READDATA, paramsf);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 0L);
|
||||
fclose(paramsf);
|
||||
paramsf = NULL;
|
||||
|
||||
/* Heartbeat GET_PARAMETERS */
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
/* POST GET_PARAMETERS */
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n");
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
|
||||
|
||||
/* Make sure we can do a normal request now */
|
||||
stream_uri = suburl(URL, request++);
|
||||
if(!stream_uri) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(paramsf)
|
||||
fclose(paramsf);
|
||||
|
||||
free(stream_uri);
|
||||
|
||||
if(custom_headers)
|
||||
curl_slist_free_all(custom_headers);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
114
3rd-party/curl-7.52.1/tests/libtest/lib573.c
vendored
Normal file
114
3rd-party/curl-7.52.1/tests/libtest/lib573.c
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "testtrace.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 = 1;
|
||||
double connect_time = 0.0;
|
||||
double dbl_epsilon;
|
||||
|
||||
dbl_epsilon = 1.0;
|
||||
do {
|
||||
dbl_epsilon /= 2.0;
|
||||
} while((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0);
|
||||
|
||||
start_test_timing();
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
easy_init(c);
|
||||
|
||||
easy_setopt(c, CURLOPT_HEADER, 1L);
|
||||
easy_setopt(c, CURLOPT_URL, URL);
|
||||
|
||||
libtest_debug_config.nohex = 1;
|
||||
libtest_debug_config.tracetime = 1;
|
||||
easy_setopt(c, CURLOPT_DEBUGDATA, &libtest_debug_config);
|
||||
easy_setopt(c, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
|
||||
easy_setopt(c, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
multi_init(m);
|
||||
|
||||
multi_add_handle(m, c);
|
||||
|
||||
while(running) {
|
||||
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();
|
||||
}
|
||||
|
||||
curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time);
|
||||
if(connect_time < dbl_epsilon) {
|
||||
fprintf(stderr, "connect time %e is < epsilon %e\n",
|
||||
connect_time, dbl_epsilon);
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
69
3rd-party/curl-7.52.1/tests/libtest/lib574.c
vendored
Normal file
69
3rd-party/curl-7.52.1/tests/libtest/lib574.c
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static int new_fnmatch(const char *pattern, const char *string)
|
||||
{
|
||||
(void)pattern;
|
||||
(void)string;
|
||||
return CURL_FNMATCHFUNC_MATCH;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int 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_WILDCARDMATCH, 1L);
|
||||
test_setopt(curl, CURLOPT_FNMATCH_FUNCTION, new_fnmatch);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res) {
|
||||
fprintf(stderr, "curl_easy_perform() failed %d\n", res);
|
||||
goto test_cleanup;
|
||||
}
|
||||
res = curl_easy_perform(curl);
|
||||
if(res) {
|
||||
fprintf(stderr, "curl_easy_perform() failed %d\n", res);
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
return res;
|
||||
}
|
114
3rd-party/curl-7.52.1/tests/libtest/lib575.c
vendored
Normal file
114
3rd-party/curl-7.52.1/tests/libtest/lib575.c
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
/* 3x download!
|
||||
* 1. normal
|
||||
* 2. dup handle
|
||||
* 3. with multi interface
|
||||
*/
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *handle = NULL;
|
||||
CURL *duphandle = 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_WILDCARDMATCH, 1L);
|
||||
easy_setopt(handle, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(handle);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
res = curl_easy_perform(handle);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
duphandle = curl_easy_duphandle(handle);
|
||||
if(!duphandle)
|
||||
goto test_cleanup;
|
||||
curl_easy_cleanup(handle);
|
||||
handle = duphandle;
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
|
||||
multi_perform(mhandle, &still_running);
|
||||
|
||||
abort_on_test_timeout();
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* undocumented cleanup sequence - type UA */
|
||||
|
||||
curl_multi_cleanup(mhandle);
|
||||
curl_easy_cleanup(handle);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
125
3rd-party/curl-7.52.1/tests/libtest/lib576.c
vendored
Normal file
125
3rd-party/curl-7.52.1/tests/libtest/lib576.c
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef struct {
|
||||
int remains;
|
||||
int print_content;
|
||||
} chunk_data_t;
|
||||
|
||||
static
|
||||
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains);
|
||||
static
|
||||
long chunk_end(void *ptr);
|
||||
|
||||
static
|
||||
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains)
|
||||
{
|
||||
chunk_data_t *ch_d = ptr;
|
||||
ch_d->remains = remains;
|
||||
|
||||
printf("=============================================================\n");
|
||||
printf("Remains: %d\n", remains);
|
||||
printf("Filename: %s\n", finfo->filename);
|
||||
if(finfo->strings.perm) {
|
||||
printf("Permissions: %s", finfo->strings.perm);
|
||||
if(finfo->flags & CURLFINFOFLAG_KNOWN_PERM)
|
||||
printf(" (parsed => %o)", finfo->perm);
|
||||
printf("\n");
|
||||
}
|
||||
printf("Size: %ldB\n", (long)finfo->size);
|
||||
if(finfo->strings.user)
|
||||
printf("User: %s\n", finfo->strings.user);
|
||||
if(finfo->strings.group)
|
||||
printf("Group: %s\n", finfo->strings.group);
|
||||
if(finfo->strings.time)
|
||||
printf("Time: %s\n", finfo->strings.time);
|
||||
printf("Filetype: ");
|
||||
switch(finfo->filetype) {
|
||||
case CURLFILETYPE_FILE:
|
||||
printf("regular file\n");
|
||||
break;
|
||||
case CURLFILETYPE_DIRECTORY:
|
||||
printf("directory\n");
|
||||
break;
|
||||
case CURLFILETYPE_SYMLINK:
|
||||
printf("symlink\n");
|
||||
printf("Target: %s\n", finfo->strings.target);
|
||||
break;
|
||||
default:
|
||||
printf("other type\n");
|
||||
break;
|
||||
}
|
||||
if(finfo->filetype == CURLFILETYPE_FILE) {
|
||||
ch_d->print_content = 1;
|
||||
printf("Content:\n-----------------------"
|
||||
"--------------------------------------\n");
|
||||
}
|
||||
if(strcmp(finfo->filename, "someothertext.txt") == 0) {
|
||||
printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n");
|
||||
return CURL_CHUNK_BGN_FUNC_SKIP;
|
||||
}
|
||||
return CURL_CHUNK_BGN_FUNC_OK;
|
||||
}
|
||||
|
||||
static
|
||||
long chunk_end(void *ptr)
|
||||
{
|
||||
chunk_data_t *ch_d = ptr;
|
||||
if(ch_d->print_content) {
|
||||
ch_d->print_content = 0;
|
||||
printf("-------------------------------------------------------------\n");
|
||||
}
|
||||
if(ch_d->remains == 1)
|
||||
printf("=============================================================\n");
|
||||
return CURL_CHUNK_END_FUNC_OK;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *handle = NULL;
|
||||
CURLcode res = CURLE_OK;
|
||||
chunk_data_t chunk_data = {0, 0};
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
handle = curl_easy_init();
|
||||
if(!handle) {
|
||||
res = CURLE_OUT_OF_MEMORY;
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
test_setopt(handle, CURLOPT_URL, URL);
|
||||
test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
|
||||
test_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, chunk_bgn);
|
||||
test_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, chunk_end);
|
||||
test_setopt(handle, CURLOPT_CHUNK_DATA, &chunk_data);
|
||||
|
||||
res = curl_easy_perform(handle);
|
||||
|
||||
test_cleanup:
|
||||
if(handle)
|
||||
curl_easy_cleanup(handle);
|
||||
curl_global_cleanup();
|
||||
return res;
|
||||
}
|
105
3rd-party/curl-7.52.1/tests/libtest/lib578.c
vendored
Normal file
105
3rd-party/curl-7.52.1/tests/libtest/lib578.c
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
/* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
|
||||
static char data[]="this is a short string.\n";
|
||||
|
||||
static size_t data_size = sizeof(data) / sizeof(char);
|
||||
|
||||
static int progress_callback(void *clientp, double dltotal, double dlnow,
|
||||
double ultotal, double ulnow)
|
||||
{
|
||||
FILE *moo = fopen(libtest_arg2, "wb");
|
||||
|
||||
(void)clientp; /* UNUSED */
|
||||
(void)dltotal; /* UNUSED */
|
||||
(void)dlnow; /* UNUSED */
|
||||
|
||||
if(moo) {
|
||||
if((size_t)ultotal == data_size && (size_t)ulnow == data_size)
|
||||
fprintf(moo, "PASSED, UL data matched data size\n");
|
||||
else
|
||||
fprintf(moo, "Progress callback called with UL %f out of %f\n",
|
||||
ulnow, ultotal);
|
||||
fclose(moo);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* Set the expected POST size */
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, data_size);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, data);
|
||||
|
||||
/* we want to use our own progress function */
|
||||
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
||||
test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
||||
|
||||
/* pointer to pass to our read function */
|
||||
|
||||
/* 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;
|
||||
}
|
162
3rd-party/curl-7.52.1/tests/libtest/lib579.c
vendored
Normal file
162
3rd-party/curl-7.52.1/tests/libtest/lib579.c
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static const char * const post[]={
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
"and a final longer crap: four",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
struct WriteThis {
|
||||
int counter;
|
||||
};
|
||||
|
||||
static int progress_callback(void *clientp, double dltotal, double dlnow,
|
||||
double ultotal, double ulnow)
|
||||
{
|
||||
FILE *moo;
|
||||
static int prev_ultotal = -1;
|
||||
static int prev_ulnow = -1;
|
||||
(void)clientp; /* UNUSED */
|
||||
(void)dltotal; /* UNUSED */
|
||||
(void)dlnow; /* UNUSED */
|
||||
|
||||
/* to avoid depending on timing, which will cause this progress function to
|
||||
get called a different number of times depending on circumstances, we
|
||||
only log these lines if the numbers are different from the previous
|
||||
invoke */
|
||||
if((prev_ultotal != (int)ultotal) ||
|
||||
(prev_ulnow != (int)ulnow)) {
|
||||
|
||||
moo = fopen(libtest_arg2, "ab");
|
||||
if(moo) {
|
||||
fprintf(moo, "Progress callback called with UL %d out of %d\n",
|
||||
(int)ulnow, (int)ultotal);
|
||||
fclose(moo);
|
||||
}
|
||||
prev_ulnow = (int) ulnow;
|
||||
prev_ultotal = (int) ultotal;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t read_callback(void *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);
|
||||
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 == NULL) {
|
||||
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);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* 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);
|
||||
|
||||
test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
|
||||
test_setopt(curl, CURLOPT_USERPWD, "foo:bar");
|
||||
|
||||
/* we want to use our own progress function */
|
||||
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
||||
test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
||||
|
||||
/* 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;
|
||||
}
|
359
3rd-party/curl-7.52.1/tests/libtest/lib582.c
vendored
Normal file
359
3rd-party/curl-7.52.1/tests/libtest/lib582.c
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
struct Sockets
|
||||
{
|
||||
curl_socket_t *sockets;
|
||||
int count; /* number of sockets actually stored in array */
|
||||
int max_count; /* max number of sockets that fit in allocated array */
|
||||
};
|
||||
|
||||
struct ReadWriteSockets
|
||||
{
|
||||
struct Sockets read, write;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a file descriptor from a sockets array.
|
||||
*/
|
||||
static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(mention)
|
||||
fprintf(stderr, "Remove socket fd %d\n", (int) fd);
|
||||
|
||||
for(i = 0; i < sockets->count; ++i) {
|
||||
if(sockets->sockets[i] == fd) {
|
||||
if(i < sockets->count - 1)
|
||||
memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
|
||||
sizeof(curl_socket_t) * (sockets->count - (i + 1)));
|
||||
--sockets->count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a file descriptor to a sockets array.
|
||||
*/
|
||||
static void addFd(struct Sockets* sockets, curl_socket_t fd, const char *what)
|
||||
{
|
||||
/**
|
||||
* To ensure we only have each file descriptor once, we remove it then add
|
||||
* it again.
|
||||
*/
|
||||
fprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what);
|
||||
removeFd(sockets, fd, 0);
|
||||
/*
|
||||
* Allocate array storage when required.
|
||||
*/
|
||||
if(!sockets->sockets) {
|
||||
sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
|
||||
if(!sockets->sockets)
|
||||
return;
|
||||
sockets->max_count = 20;
|
||||
}
|
||||
else if(sockets->count + 1 > sockets->max_count) {
|
||||
curl_socket_t *oldptr = sockets->sockets;
|
||||
sockets->sockets = realloc(oldptr, sizeof(curl_socket_t) *
|
||||
(sockets->max_count + 20));
|
||||
if(!sockets->sockets) {
|
||||
/* cleanup in test_cleanup */
|
||||
sockets->sockets = oldptr;
|
||||
return;
|
||||
}
|
||||
sockets->max_count += 20;
|
||||
}
|
||||
/*
|
||||
* Add file descriptor to array.
|
||||
*/
|
||||
sockets->sockets[sockets->count] = fd;
|
||||
++sockets->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback invoked by curl to poll reading / writing of a socket.
|
||||
*/
|
||||
static int curlSocketCallback(CURL *easy, curl_socket_t s, int action,
|
||||
void *userp, void *socketp)
|
||||
{
|
||||
struct ReadWriteSockets* sockets = userp;
|
||||
|
||||
(void)easy; /* unused */
|
||||
(void)socketp; /* unused */
|
||||
|
||||
if(action == CURL_POLL_IN || action == CURL_POLL_INOUT)
|
||||
addFd(&sockets->read, s, "read");
|
||||
|
||||
if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
|
||||
addFd(&sockets->write, s, "write");
|
||||
|
||||
if(action == CURL_POLL_REMOVE) {
|
||||
removeFd(&sockets->read, s, 1);
|
||||
removeFd(&sockets->write, s, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback invoked by curl to set a timeout.
|
||||
*/
|
||||
static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
|
||||
{
|
||||
struct timeval* timeout = userp;
|
||||
|
||||
(void)multi; /* unused */
|
||||
if(timeout_ms != -1) {
|
||||
*timeout = tutil_tvnow();
|
||||
timeout->tv_usec += timeout_ms * 1000;
|
||||
}
|
||||
else {
|
||||
timeout->tv_sec = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for curl completion.
|
||||
*/
|
||||
static int checkForCompletion(CURLM *curl, int *success)
|
||||
{
|
||||
int numMessages;
|
||||
CURLMsg *message;
|
||||
int result = 0;
|
||||
*success = 0;
|
||||
while((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
|
||||
if(message->msg == CURLMSG_DONE) {
|
||||
result = 1;
|
||||
if(message->data.result == CURLE_OK)
|
||||
*success = 1;
|
||||
else
|
||||
*success = 0;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Got an unexpected message from curl: %i\n",
|
||||
(int)message->msg);
|
||||
result = 1;
|
||||
*success = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int getMicroSecondTimeout(struct timeval* timeout)
|
||||
{
|
||||
struct timeval now;
|
||||
ssize_t result;
|
||||
now = tutil_tvnow();
|
||||
result = (timeout->tv_sec - now.tv_sec) * 1000000 +
|
||||
timeout->tv_usec - now.tv_usec;
|
||||
if(result < 0)
|
||||
result = 0;
|
||||
|
||||
return curlx_sztosi(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a fd_set with all of the sockets in use.
|
||||
*/
|
||||
static void updateFdSet(struct Sockets* sockets, fd_set* fdset,
|
||||
curl_socket_t *maxFd)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < sockets->count; ++i) {
|
||||
FD_SET(sockets->sockets[i], fdset);
|
||||
if(*maxFd < sockets->sockets[i] + 1) {
|
||||
*maxFd = sockets->sockets[i] + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void notifyCurl(CURLM *curl, curl_socket_t s, int evBitmask,
|
||||
const char *info)
|
||||
{
|
||||
int numhandles = 0;
|
||||
CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles);
|
||||
if(result != CURLM_OK) {
|
||||
fprintf(stderr, "Curl error on %s: %i (%s)\n",
|
||||
info, result, curl_multi_strerror(result));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke curl when a file descriptor is set.
|
||||
*/
|
||||
static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset,
|
||||
int evBitmask, const char *name)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < sockets->count; ++i) {
|
||||
if(FD_ISSET(sockets->sockets[i], fdset)) {
|
||||
notifyCurl(curl, sockets->sockets[i], evBitmask, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int res = 0;
|
||||
CURL *curl = NULL;
|
||||
FILE *hd_src = NULL;
|
||||
int hd;
|
||||
int error;
|
||||
struct_stat file_info;
|
||||
CURLM *m = NULL;
|
||||
struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
|
||||
struct timeval timeout = {-1, 0};
|
||||
int success = 0;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
if(!libtest_arg3) {
|
||||
fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n");
|
||||
return TEST_ERR_USAGE;
|
||||
}
|
||||
|
||||
hd_src = fopen(libtest_arg2, "rb");
|
||||
if(NULL == hd_src) {
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
|
||||
return TEST_ERR_FOPEN;
|
||||
}
|
||||
|
||||
/* get the file size of the local file */
|
||||
hd = fstat(fileno(hd_src), &file_info);
|
||||
if(hd == -1) {
|
||||
/* can't open file, bail out */
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
|
||||
fclose(hd_src);
|
||||
return TEST_ERR_FSTAT;
|
||||
}
|
||||
fprintf(stderr, "Set to upload %d bytes\n", (int)file_info.st_size);
|
||||
|
||||
res_global_init(CURL_GLOBAL_ALL);
|
||||
if(res) {
|
||||
fclose(hd_src);
|
||||
return res;
|
||||
}
|
||||
|
||||
easy_init(curl);
|
||||
|
||||
/* enable uploading */
|
||||
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* specify target */
|
||||
easy_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* go verbose */
|
||||
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* now specify which file to upload */
|
||||
easy_setopt(curl, CURLOPT_READDATA, hd_src);
|
||||
|
||||
easy_setopt(curl, CURLOPT_USERPWD, libtest_arg3);
|
||||
easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
|
||||
easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
|
||||
|
||||
easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
|
||||
|
||||
multi_init(m);
|
||||
|
||||
multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback);
|
||||
multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets);
|
||||
|
||||
multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback);
|
||||
multi_setopt(m, CURLMOPT_TIMERDATA, &timeout);
|
||||
|
||||
multi_add_handle(m, curl);
|
||||
|
||||
while(!checkForCompletion(m, &success)) {
|
||||
fd_set readSet, writeSet;
|
||||
curl_socket_t maxFd = 0;
|
||||
struct timeval tv = {10, 0};
|
||||
|
||||
FD_ZERO(&readSet);
|
||||
FD_ZERO(&writeSet);
|
||||
updateFdSet(&sockets.read, &readSet, &maxFd);
|
||||
updateFdSet(&sockets.write, &writeSet, &maxFd);
|
||||
|
||||
if(timeout.tv_sec != -1) {
|
||||
int usTimeout = getMicroSecondTimeout(&timeout);
|
||||
tv.tv_sec = usTimeout / 1000000;
|
||||
tv.tv_usec = usTimeout % 1000000;
|
||||
}
|
||||
else if(maxFd <= 0) {
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100000;
|
||||
}
|
||||
|
||||
select_test(maxFd, &readSet, &writeSet, NULL, &tv);
|
||||
|
||||
/* Check the sockets for reading / writing */
|
||||
checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
|
||||
checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
|
||||
|
||||
if(timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) {
|
||||
/* Curl's timer has elapsed. */
|
||||
notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout");
|
||||
}
|
||||
|
||||
abort_on_test_timeout();
|
||||
}
|
||||
|
||||
if(!success) {
|
||||
fprintf(stderr, "Error uploading file.\n");
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* proper cleanup sequence - type PB */
|
||||
|
||||
curl_multi_remove_handle(m, curl);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
/* close the local file */
|
||||
fclose(hd_src);
|
||||
|
||||
/* free local memory */
|
||||
free(sockets.read.sockets);
|
||||
free(sockets.write.sockets);
|
||||
|
||||
return res;
|
||||
}
|
84
3rd-party/curl-7.52.1/tests/libtest/lib583.c
vendored
Normal file
84
3rd-party/curl-7.52.1/tests/libtest/lib583.c
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
* This test case is based on the sample code provided by Saqib Ali
|
||||
* https://curl.haxx.se/mail/lib-2011-03/0066.html
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
int stillRunning;
|
||||
CURLM *multiHandle = NULL;
|
||||
CURL *curl = NULL;
|
||||
int res = 0;
|
||||
|
||||
global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
multi_init(multiHandle);
|
||||
|
||||
easy_init(curl);
|
||||
|
||||
easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
|
||||
easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
|
||||
easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
|
||||
|
||||
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
easy_setopt(curl, CURLOPT_URL, URL);
|
||||
easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
|
||||
|
||||
multi_add_handle(multiHandle, curl);
|
||||
|
||||
/* this tests if removing an easy handle immediately after multi
|
||||
perform has been called succeeds or not. */
|
||||
|
||||
fprintf(stderr, "curl_multi_perform()...\n");
|
||||
|
||||
multi_perform(multiHandle, &stillRunning);
|
||||
|
||||
fprintf(stderr, "curl_multi_perform() succeeded\n");
|
||||
|
||||
fprintf(stderr, "curl_multi_remove_handle()...\n");
|
||||
res = (int) curl_multi_remove_handle(multiHandle, curl);
|
||||
if(res)
|
||||
fprintf(stderr, "curl_multi_remove_handle() failed, "
|
||||
"with code %d\n", res);
|
||||
else
|
||||
fprintf(stderr, "curl_multi_remove_handle() succeeded\n");
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* undocumented cleanup sequence - type UB */
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_multi_cleanup(multiHandle);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
247
3rd-party/curl-7.52.1/tests/libtest/lib586.c
vendored
Normal file
247
3rd-party/curl-7.52.1/tests/libtest/lib586.c
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define THREADS 2
|
||||
|
||||
/* struct containing data of a thread */
|
||||
struct Tdata {
|
||||
CURLSH *share;
|
||||
char *url;
|
||||
};
|
||||
|
||||
struct userdata {
|
||||
char *text;
|
||||
int counter;
|
||||
};
|
||||
|
||||
/* 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;
|
||||
|
||||
(void)handle;
|
||||
(void)laccess;
|
||||
|
||||
switch(data) {
|
||||
case CURL_LOCK_DATA_SHARE:
|
||||
what = "share";
|
||||
break;
|
||||
case CURL_LOCK_DATA_DNS:
|
||||
what = "dns";
|
||||
break;
|
||||
case CURL_LOCK_DATA_COOKIE:
|
||||
what = "cookie";
|
||||
break;
|
||||
case CURL_LOCK_DATA_SSL_SESSION:
|
||||
what = "ssl_session";
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "lock: no such data: %d\n", (int)data);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
(void)handle;
|
||||
switch(data) {
|
||||
case CURL_LOCK_DATA_SHARE:
|
||||
what = "share";
|
||||
break;
|
||||
case CURL_LOCK_DATA_DNS:
|
||||
what = "dns";
|
||||
break;
|
||||
case CURL_LOCK_DATA_COOKIE:
|
||||
what = "cookie";
|
||||
break;
|
||||
case CURL_LOCK_DATA_SSL_SESSION:
|
||||
what = "ssl_session";
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unlock: no such data: %d\n", (int)data);
|
||||
return;
|
||||
}
|
||||
printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
|
||||
user->counter++;
|
||||
}
|
||||
|
||||
/* the dummy thread function */
|
||||
static void *fire(void *ptr)
|
||||
{
|
||||
CURLcode code;
|
||||
struct Tdata *tdata = (struct Tdata*)ptr;
|
||||
CURL *curl;
|
||||
int i=0;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
|
||||
printf("CURLOPT_SHARE\n");
|
||||
curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
|
||||
|
||||
printf("PERFORM\n");
|
||||
code = curl_easy_perform(curl);
|
||||
if(code != CURLE_OK) {
|
||||
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
|
||||
tdata->url, i, (int)code);
|
||||
}
|
||||
|
||||
printf("CLEANUP\n");
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* test function */
|
||||
int test(char *URL)
|
||||
{
|
||||
int res;
|
||||
CURLSHcode scode = CURLSHE_OK;
|
||||
char *url;
|
||||
struct Tdata tdata;
|
||||
CURL *curl;
|
||||
CURLSH *share;
|
||||
int i;
|
||||
struct userdata user;
|
||||
|
||||
user.text = (char *)"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_SSL_SESSION\n");
|
||||
scode = curl_share_setopt(share, CURLSHOPT_SHARE,
|
||||
CURL_LOCK_DATA_SSL_SESSION);
|
||||
}
|
||||
|
||||
if(CURLSHE_OK != scode) {
|
||||
fprintf(stderr, "curl_share_setopt() failed\n");
|
||||
curl_share_cleanup(share);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
|
||||
res = 0;
|
||||
|
||||
/* start treads */
|
||||
for(i=1; i<=THREADS; i++) {
|
||||
|
||||
/* set thread data */
|
||||
tdata.url = URL;
|
||||
tdata.share = share;
|
||||
|
||||
/* simulate thread, direct call of "thread" function */
|
||||
printf("*** run %d\n",i);
|
||||
fire(&tdata);
|
||||
}
|
||||
|
||||
|
||||
/* fetch a another one */
|
||||
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 = URL;
|
||||
test_setopt(curl, CURLOPT_URL, url);
|
||||
printf("CURLOPT_SHARE\n");
|
||||
test_setopt(curl, CURLOPT_SHARE, share);
|
||||
|
||||
printf("PERFORM\n");
|
||||
curl_easy_perform(curl);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
72
3rd-party/curl-7.52.1/tests/libtest/lib590.c
vendored
Normal file
72
3rd-party/curl-7.52.1/tests/libtest/lib590.c
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
Based on a bug report recipe by Rene Bernhardt in
|
||||
https://curl.haxx.se/mail/lib-2011-10/0323.html
|
||||
|
||||
It is reproducible by the following steps:
|
||||
|
||||
- Use a proxy that offers NTLM and Negotiate ( CURLOPT_PROXY and
|
||||
CURLOPT_PROXYPORT)
|
||||
- Tell libcurl NOT to use Negotiate CURL_EASY_SETOPT(CURLOPT_PROXYAUTH,
|
||||
CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM)
|
||||
- Start the request
|
||||
*/
|
||||
|
||||
#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_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_PROXYAUTH,
|
||||
(long) (CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM));
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
|
||||
test_setopt(curl, CURLOPT_PROXYUSERPWD, "me:password");
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
149
3rd-party/curl-7.52.1/tests/libtest/lib591.c
vendored
Normal file
149
3rd-party/curl-7.52.1/tests/libtest/lib591.c
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2012, 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.
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
/* lib591 is used for test cases 591, 592, 593 and 594 */
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "testutil.h"
|
||||
#include "warnless.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#define TEST_HANG_TIMEOUT 60 * 1000
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *easy = NULL;
|
||||
CURLM *multi = NULL;
|
||||
int res = 0;
|
||||
int running;
|
||||
int msgs_left;
|
||||
CURLMsg *msg;
|
||||
FILE *upload = NULL;
|
||||
int error;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
upload = fopen(libtest_arg3, "rb");
|
||||
if(!upload) {
|
||||
error = ERRNO;
|
||||
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg3);
|
||||
return TEST_ERR_FOPEN;
|
||||
}
|
||||
|
||||
res_global_init(CURL_GLOBAL_ALL);
|
||||
if(res) {
|
||||
fclose(upload);
|
||||
return res;
|
||||
}
|
||||
|
||||
easy_init(easy);
|
||||
|
||||
/* go verbose */
|
||||
easy_setopt(easy, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* specify target */
|
||||
easy_setopt(easy, CURLOPT_URL, URL);
|
||||
|
||||
/* enable uploading */
|
||||
easy_setopt(easy, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* data pointer for the file read function */
|
||||
easy_setopt(easy, CURLOPT_READDATA, upload);
|
||||
|
||||
/* use active mode FTP */
|
||||
easy_setopt(easy, CURLOPT_FTPPORT, "-");
|
||||
|
||||
/* server connection timeout */
|
||||
easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS,
|
||||
strtol(libtest_arg2, NULL, 10)*1000);
|
||||
|
||||
multi_init(multi);
|
||||
|
||||
multi_add_handle(multi, easy);
|
||||
|
||||
for(;;) {
|
||||
struct timeval interval;
|
||||
fd_set fdread;
|
||||
fd_set fdwrite;
|
||||
fd_set fdexcep;
|
||||
long timeout = -99;
|
||||
int maxfd = -99;
|
||||
|
||||
multi_perform(multi, &running);
|
||||
|
||||
abort_on_test_timeout();
|
||||
|
||||
if(!running)
|
||||
break; /* done */
|
||||
|
||||
FD_ZERO(&fdread);
|
||||
FD_ZERO(&fdwrite);
|
||||
FD_ZERO(&fdexcep);
|
||||
|
||||
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
|
||||
|
||||
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
|
||||
|
||||
multi_timeout(multi, &timeout);
|
||||
|
||||
/* At this point, timeout is guaranteed to be greater or equal than -1. */
|
||||
|
||||
if(timeout != -1L) {
|
||||
int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
|
||||
interval.tv_sec = itimeout/1000;
|
||||
interval.tv_usec = (itimeout%1000)*1000;
|
||||
}
|
||||
else {
|
||||
interval.tv_sec = 0;
|
||||
interval.tv_usec = 100000L; /* 100 ms */
|
||||
}
|
||||
|
||||
select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
|
||||
|
||||
abort_on_test_timeout();
|
||||
}
|
||||
|
||||
msg = curl_multi_info_read(multi, &msgs_left);
|
||||
if(msg)
|
||||
res = msg->data.result;
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* undocumented cleanup sequence - type UA */
|
||||
|
||||
curl_multi_cleanup(multi);
|
||||
curl_easy_cleanup(easy);
|
||||
curl_global_cleanup();
|
||||
|
||||
/* close the local file */
|
||||
fclose(upload);
|
||||
|
||||
return res;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user