From 9c35acfc63b94c152018263224a17bdecfcaf274 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 15 Jan 2023 02:17:12 +0900 Subject: [PATCH] added cgi test code --- bin/Makefile.am | 97 +++++++++++++++++++++++++------------------------ bin/Makefile.in | 59 ++++++++++++++++++------------ lib/http-cgi.c | 4 ++ t/Makefile.am | 10 ++++- t/Makefile.in | 78 +++++++++++++++++++++++++++++++-------- t/s-001.sh | 28 +++++++++++++- t/t-cgi.c | 33 +++++++++++++++++ 7 files changed, 220 insertions(+), 89 deletions(-) create mode 100644 t/t-cgi.c diff --git a/bin/Makefile.am b/bin/Makefile.am index 048c0a5..3a548b1 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -34,53 +34,6 @@ hio_te_LDFLAGS = $(LDFLAGS_COMMON) hio_te_LDADD = $(LIBADD_COMMON) -lX11 endif -bin_PROGRAMS += hio-t01 -hio_t01_SOURCES = t01.c -hio_t01_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_t01_CFLAGS = $(CFLAGS_COMMON) -hio_t01_LDFLAGS = $(LDFLAGS_COMMON) -hio_t01_LDADD = $(LIBADD_COMMON) - -bin_PROGRAMS += hio-t02 -hio_t02_SOURCES = t02.c -hio_t02_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_t02_CFLAGS = $(CFLAGS_COMMON) -hio_t02_LDFLAGS = $(LDFLAGS_COMMON) -hio_t02_LDADD = $(LIBADD_COMMON) - -bin_PROGRAMS += hio-t03 -hio_t03_SOURCES = t03.c -hio_t03_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_t03_CFLAGS = $(CFLAGS_COMMON) -hio_t03_LDFLAGS = $(LDFLAGS_COMMON) -hio_t03_LDADD = $(LIBADD_COMMON) - -bin_PROGRAMS += hio-t04 -hio_t04_SOURCES = t04.c -hio_t04_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_t04_CFLAGS = $(CFLAGS_COMMON) -hio_t04_LDFLAGS = $(LDFLAGS_COMMON) -hio_t04_LDADD = $(LIBADD_COMMON) -if ENABLE_MARIADB -hio_t04_CFLAGS += $(MARIADB_CFLAGS) -hio_t04_LDFLAGS += $(MARIADB_LDFLAGS) -hio_t04_LDADD += $(MARIADB_LIBS) -endif - -bin_PROGRAMS += hio-t05 -hio_t05_SOURCES = t05.c -hio_t05_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_t05_CFLAGS = $(CFLAGS_COMMON) -hio_t05_LDFLAGS = $(LDFLAGS_COMMON) -hio_t05_LDADD = $(LIBADD_COMMON) - -bin_PROGRAMS += hio-t06 -hio_t06_SOURCES = t06.c -hio_t06_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_t06_CFLAGS = $(CFLAGS_COMMON) -hio_t06_LDFLAGS = $(LDFLAGS_COMMON) -hio_t06_LDADD = $(LIBADD_COMMON) - bin_PROGRAMS += hio-untar hio_untar_SOURCES = untar.c hio_untar_CPPFLAGS = $(CPPFLAGS_COMMON) @@ -94,3 +47,53 @@ hio_webs_CPPFLAGS = $(CPPFLAGS_COMMON) hio_webs_CFLAGS = $(CFLAGS_COMMON) hio_webs_LDFLAGS = $(LDFLAGS_COMMON) $(LDFLAGS_ALL_STATIC) hio_webs_LDADD = $(LIBADD_COMMON) $(LIBADD_ALL_STATIC) + + +# ------------------------------------------------- + +noinst_PROGRAMS = hio-t01 +hio_t01_SOURCES = t01.c +hio_t01_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_t01_CFLAGS = $(CFLAGS_COMMON) +hio_t01_LDFLAGS = $(LDFLAGS_COMMON) +hio_t01_LDADD = $(LIBADD_COMMON) + +noinst_PROGRAMS += hio-t02 +hio_t02_SOURCES = t02.c +hio_t02_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_t02_CFLAGS = $(CFLAGS_COMMON) +hio_t02_LDFLAGS = $(LDFLAGS_COMMON) +hio_t02_LDADD = $(LIBADD_COMMON) + +noinst_PROGRAMS += hio-t03 +hio_t03_SOURCES = t03.c +hio_t03_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_t03_CFLAGS = $(CFLAGS_COMMON) +hio_t03_LDFLAGS = $(LDFLAGS_COMMON) +hio_t03_LDADD = $(LIBADD_COMMON) + +noinst_PROGRAMS += hio-t04 +hio_t04_SOURCES = t04.c +hio_t04_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_t04_CFLAGS = $(CFLAGS_COMMON) +hio_t04_LDFLAGS = $(LDFLAGS_COMMON) +hio_t04_LDADD = $(LIBADD_COMMON) +if ENABLE_MARIADB +hio_t04_CFLAGS += $(MARIADB_CFLAGS) +hio_t04_LDFLAGS += $(MARIADB_LDFLAGS) +hio_t04_LDADD += $(MARIADB_LIBS) +endif + +noinst_PROGRAMS += hio-t05 +hio_t05_SOURCES = t05.c +hio_t05_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_t05_CFLAGS = $(CFLAGS_COMMON) +hio_t05_LDFLAGS = $(LDFLAGS_COMMON) +hio_t05_LDADD = $(LIBADD_COMMON) + +noinst_PROGRAMS += hio-t06 +hio_t06_SOURCES = t06.c +hio_t06_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_t06_CFLAGS = $(CFLAGS_COMMON) +hio_t06_LDFLAGS = $(LDFLAGS_COMMON) +hio_t06_LDADD = $(LIBADD_COMMON) diff --git a/bin/Makefile.in b/bin/Makefile.in index f0f849c..0e16873 100644 --- a/bin/Makefile.in +++ b/bin/Makefile.in @@ -88,11 +88,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -bin_PROGRAMS = hio-execd$(EXEEXT) $(am__EXEEXT_1) hio-t01$(EXEEXT) \ - hio-t02$(EXEEXT) hio-t03$(EXEEXT) hio-t04$(EXEEXT) \ - hio-t05$(EXEEXT) hio-t06$(EXEEXT) hio-untar$(EXEEXT) \ +bin_PROGRAMS = hio-execd$(EXEEXT) $(am__EXEEXT_1) hio-untar$(EXEEXT) \ hio-webs$(EXEEXT) @HAVE_X11_LIB_TRUE@am__append_1 = hio-te +noinst_PROGRAMS = hio-t01$(EXEEXT) hio-t02$(EXEEXT) hio-t03$(EXEEXT) \ + hio-t04$(EXEEXT) hio-t05$(EXEEXT) hio-t06$(EXEEXT) @ENABLE_MARIADB_TRUE@am__append_2 = $(MARIADB_CFLAGS) @ENABLE_MARIADB_TRUE@am__append_3 = $(MARIADB_LDFLAGS) @ENABLE_MARIADB_TRUE@am__append_4 = $(MARIADB_LIBS) @@ -113,7 +113,7 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_X11_LIB_TRUE@am__EXEEXT_1 = hio-te$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" -PROGRAMS = $(bin_PROGRAMS) +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am_hio_execd_OBJECTS = hio_execd-execd.$(OBJEXT) hio_execd_OBJECTS = $(am_hio_execd_OBJECTS) hio_execd_DEPENDENCIES = $(LIBADD_COMMON) @@ -418,6 +418,16 @@ hio_execd_LDADD = $(LIBADD_COMMON) @HAVE_X11_LIB_TRUE@hio_te_CFLAGS = $(CFLAGS_COMMON) @HAVE_X11_LIB_TRUE@hio_te_LDFLAGS = $(LDFLAGS_COMMON) @HAVE_X11_LIB_TRUE@hio_te_LDADD = $(LIBADD_COMMON) -lX11 +hio_untar_SOURCES = untar.c +hio_untar_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_untar_CFLAGS = $(CFLAGS_COMMON) +hio_untar_LDFLAGS = $(LDFLAGS_COMMON) +hio_untar_LDADD = $(LIBADD_COMMON) +hio_webs_SOURCES = webs.c +hio_webs_CPPFLAGS = $(CPPFLAGS_COMMON) +hio_webs_CFLAGS = $(CFLAGS_COMMON) +hio_webs_LDFLAGS = $(LDFLAGS_COMMON) $(LDFLAGS_ALL_STATIC) +hio_webs_LDADD = $(LIBADD_COMMON) $(LIBADD_ALL_STATIC) hio_t01_SOURCES = t01.c hio_t01_CPPFLAGS = $(CPPFLAGS_COMMON) hio_t01_CFLAGS = $(CFLAGS_COMMON) @@ -448,16 +458,6 @@ hio_t06_CPPFLAGS = $(CPPFLAGS_COMMON) hio_t06_CFLAGS = $(CFLAGS_COMMON) hio_t06_LDFLAGS = $(LDFLAGS_COMMON) hio_t06_LDADD = $(LIBADD_COMMON) -hio_untar_SOURCES = untar.c -hio_untar_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_untar_CFLAGS = $(CFLAGS_COMMON) -hio_untar_LDFLAGS = $(LDFLAGS_COMMON) -hio_untar_LDADD = $(LIBADD_COMMON) -hio_webs_SOURCES = webs.c -hio_webs_CPPFLAGS = $(CPPFLAGS_COMMON) -hio_webs_CFLAGS = $(CFLAGS_COMMON) -hio_webs_LDFLAGS = $(LDFLAGS_COMMON) $(LDFLAGS_ALL_STATIC) -hio_webs_LDADD = $(LIBADD_COMMON) $(LIBADD_ALL_STATIC) all: all-am .SUFFIXES: @@ -541,6 +541,15 @@ clean-binPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + hio-execd$(EXEEXT): $(hio_execd_OBJECTS) $(hio_execd_DEPENDENCIES) $(EXTRA_hio_execd_DEPENDENCIES) @rm -f hio-execd$(EXEEXT) $(AM_V_CCLD)$(hio_execd_LINK) $(hio_execd_OBJECTS) $(hio_execd_LDADD) $(LIBS) @@ -898,7 +907,8 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/hio_execd-execd.Po @@ -987,15 +997,16 @@ uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ - clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-binPROGRAMS \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ + clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS diff --git a/lib/http-cgi.c b/lib/http-cgi.c index 888c39c..240aee2 100644 --- a/lib/http-cgi.c +++ b/lib/http-cgi.c @@ -869,6 +869,9 @@ static int cgi_peer_on_fork (hio_dev_pro_t* pro, void* fork_ctx) hio_becs_t dbuf; qparam = hio_htre_getqparam(fc->req); + /* the anchor/fragment is never part of the server-side URL. + * the client must discard that part before sending to the server. + * hio_htre_getqanchor() is just disregarded here. */ tmpstr = getenv("PATH"); if (!tmpstr) tmpstr = ""; @@ -917,6 +920,7 @@ static int cgi_peer_on_fork (hio_dev_pro_t* pro, void* fork_ctx) setenv ("REQUEST_METHOD", hio_htre_getqmethodname(fc->req), 1); setenv ("REQUEST_URI", hio_htre_getqpath(fc->req), 1); + if (qparam) setenv ("QUERY_STRING", qparam, 1); if (hio_htre_getreqcontentlen(fc->req, &content_length) == 0) diff --git a/t/Makefile.am b/t/Makefile.am index 14c2be4..471f1df 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -8,11 +8,19 @@ CPPFLAGS_COMMON = \ -I$(includedir) CFLAGS_COMMON = LDFLAGS_COMMON=-L$(abs_builddir)/../lib -L$(libdir) -## place $(LIBM) here as all programs below are C only programs linked +## place $(LIBM) here as all programs below are C only programs linked ## against the C/C++ hybrid library. Read comments in ../bin/Makefile.am ## for more information. LIBADD_COMMON = ../lib/libhio.la $(LIBM) + +noinst_PROGRAMS = t-cgi +t_cgi_source = t-cgi.c +t_cgi_CPPFLAGS = $(CPPFLAGS_COMMON) +t_cgi_CFLAGS = $(CFLAGS_COMMON) +t_cgi_LDFLAGS = $(LDFLAGS_COMMON) +t_cgi_LDADD = $(LIBADD_COMMON) + check_SCRIPTS = s-001.sh EXTRA_DIST = $(check_SCRIPTS) diff --git a/t/Makefile.in b/t/Makefile.in index d5a71d6..426dad6 100644 --- a/t/Makefile.in +++ b/t/Makefile.in @@ -13,6 +13,7 @@ # PARTICULAR PURPOSE. @SET_MAKE@ + VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -87,6 +88,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +noinst_PROGRAMS = t-cgi$(EXEEXT) check_PROGRAMS = t-001$(EXEEXT) t-002$(EXEEXT) t-003$(EXEEXT) \ t-004$(EXEEXT) t-005$(EXEEXT) subdir = t @@ -104,6 +106,7 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/lib/hio-cfg.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) am_t_001_OBJECTS = t_001-t-001.$(OBJEXT) t_001_OBJECTS = $(am_t_001_OBJECTS) am__DEPENDENCIES_1 = @@ -140,6 +143,12 @@ t_005_DEPENDENCIES = $(am__DEPENDENCIES_2) t_005_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(t_005_CFLAGS) $(CFLAGS) \ $(t_005_LDFLAGS) $(LDFLAGS) -o $@ +t_cgi_SOURCES = t-cgi.c +t_cgi_OBJECTS = t_cgi-t-cgi.$(OBJEXT) +t_cgi_DEPENDENCIES = $(am__DEPENDENCIES_2) +t_cgi_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(t_cgi_CFLAGS) $(CFLAGS) \ + $(t_cgi_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -157,7 +166,8 @@ depcomp = $(SHELL) $(top_srcdir)/ac/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/t_001-t-001.Po \ ./$(DEPDIR)/t_002-t-002.Po ./$(DEPDIR)/t_003-t-003.Po \ - ./$(DEPDIR)/t_004-t-004.Po ./$(DEPDIR)/t_005-t-005.Po + ./$(DEPDIR)/t_004-t-004.Po ./$(DEPDIR)/t_005-t-005.Po \ + ./$(DEPDIR)/t_cgi-t-cgi.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -178,9 +188,9 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(t_001_SOURCES) $(t_002_SOURCES) $(t_003_SOURCES) \ - $(t_004_SOURCES) $(t_005_SOURCES) + $(t_004_SOURCES) $(t_005_SOURCES) t-cgi.c DIST_SOURCES = $(t_001_SOURCES) $(t_002_SOURCES) $(t_003_SOURCES) \ - $(t_004_SOURCES) $(t_005_SOURCES) + $(t_004_SOURCES) $(t_005_SOURCES) t-cgi.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -557,6 +567,11 @@ CPPFLAGS_COMMON = \ CFLAGS_COMMON = LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir) LIBADD_COMMON = ../lib/libhio.la $(LIBM) +t_cgi_source = t-cgi.c +t_cgi_CPPFLAGS = $(CPPFLAGS_COMMON) +t_cgi_CFLAGS = $(CFLAGS_COMMON) +t_cgi_LDFLAGS = $(LDFLAGS_COMMON) +t_cgi_LDADD = $(LIBADD_COMMON) check_SCRIPTS = s-001.sh EXTRA_DIST = $(check_SCRIPTS) t_001_SOURCES = t-001.c t.h @@ -632,6 +647,15 @@ clean-checkPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + t-001$(EXEEXT): $(t_001_OBJECTS) $(t_001_DEPENDENCIES) $(EXTRA_t_001_DEPENDENCIES) @rm -f t-001$(EXEEXT) $(AM_V_CCLD)$(t_001_LINK) $(t_001_OBJECTS) $(t_001_LDADD) $(LIBS) @@ -652,6 +676,10 @@ t-005$(EXEEXT): $(t_005_OBJECTS) $(t_005_DEPENDENCIES) $(EXTRA_t_005_DEPENDENCIE @rm -f t-005$(EXEEXT) $(AM_V_CCLD)$(t_005_LINK) $(t_005_OBJECTS) $(t_005_LDADD) $(LIBS) +t-cgi$(EXEEXT): $(t_cgi_OBJECTS) $(t_cgi_DEPENDENCIES) $(EXTRA_t_cgi_DEPENDENCIES) + @rm -f t-cgi$(EXEEXT) + $(AM_V_CCLD)$(t_cgi_LINK) $(t_cgi_OBJECTS) $(t_cgi_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -663,6 +691,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_003-t-003.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_004-t-004.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_005-t-005.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_cgi-t-cgi.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -764,6 +793,20 @@ t_005-t-005.obj: t-005.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(t_005_CPPFLAGS) $(CPPFLAGS) $(t_005_CFLAGS) $(CFLAGS) -c -o t_005-t-005.obj `if test -f 't-005.c'; then $(CYGPATH_W) 't-005.c'; else $(CYGPATH_W) '$(srcdir)/t-005.c'; fi` +t_cgi-t-cgi.o: t-cgi.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(t_cgi_CPPFLAGS) $(CPPFLAGS) $(t_cgi_CFLAGS) $(CFLAGS) -MT t_cgi-t-cgi.o -MD -MP -MF $(DEPDIR)/t_cgi-t-cgi.Tpo -c -o t_cgi-t-cgi.o `test -f 't-cgi.c' || echo '$(srcdir)/'`t-cgi.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/t_cgi-t-cgi.Tpo $(DEPDIR)/t_cgi-t-cgi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t-cgi.c' object='t_cgi-t-cgi.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(t_cgi_CPPFLAGS) $(CPPFLAGS) $(t_cgi_CFLAGS) $(CFLAGS) -c -o t_cgi-t-cgi.o `test -f 't-cgi.c' || echo '$(srcdir)/'`t-cgi.c + +t_cgi-t-cgi.obj: t-cgi.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(t_cgi_CPPFLAGS) $(CPPFLAGS) $(t_cgi_CFLAGS) $(CFLAGS) -MT t_cgi-t-cgi.obj -MD -MP -MF $(DEPDIR)/t_cgi-t-cgi.Tpo -c -o t_cgi-t-cgi.obj `if test -f 't-cgi.c'; then $(CYGPATH_W) 't-cgi.c'; else $(CYGPATH_W) '$(srcdir)/t-cgi.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/t_cgi-t-cgi.Tpo $(DEPDIR)/t_cgi-t-cgi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t-cgi.c' object='t_cgi-t-cgi.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(t_cgi_CPPFLAGS) $(CPPFLAGS) $(t_cgi_CFLAGS) $(CFLAGS) -c -o t_cgi-t-cgi.obj `if test -f 't-cgi.c'; then $(CYGPATH_W) 't-cgi.c'; else $(CYGPATH_W) '$(srcdir)/t-cgi.c'; fi` + mostlyclean-libtool: -rm -f *.lo @@ -1050,7 +1093,7 @@ check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_SCRIPTS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am -all-am: Makefile +all-am: Makefile $(PROGRAMS) installdirs: install: install-am install-exec: install-exec-am @@ -1088,7 +1131,7 @@ maintainer-clean-generic: clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ - mostlyclean-am + clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/t_001-t-001.Po @@ -1096,6 +1139,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/t_003-t-003.Po -rm -f ./$(DEPDIR)/t_004-t-004.Po -rm -f ./$(DEPDIR)/t_005-t-005.Po + -rm -f ./$(DEPDIR)/t_cgi-t-cgi.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1146,6 +1190,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/t_003-t-003.Po -rm -f ./$(DEPDIR)/t_004-t-004.Po -rm -f ./$(DEPDIR)/t_005-t-005.Po + -rm -f ./$(DEPDIR)/t_cgi-t-cgi.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1168,17 +1213,18 @@ uninstall-am: .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ check-am clean clean-checkPROGRAMS clean-generic clean-libtool \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am + clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am recheck tags tags-am uninstall \ + uninstall-am .PRECIOUS: Makefile diff --git a/t/s-001.sh b/t/s-001.sh index 1e24ec3..271f20f 100644 --- a/t/s-001.sh +++ b/t/s-001.sh @@ -3,7 +3,7 @@ [ -z "$srcdir" ] && srcdir=$(dirname "$0") . "${srcdir}/tap.inc" -test_default_index() +test_default_index() { local msg="hio-webs default index.html under a directory" local srvaddr=127.0.0.1:54321 @@ -59,6 +59,32 @@ test_file_list_dir() wait ${jid} } + +test_cgi() +{ + local msg="hio-webs file-list-dir" + local srvaddr=127.0.0.1:54321 + local tmpdir="/tmp/s-001.$$" + + mkdir -p "${tmpdir}" + cp -pf t-cgi "${tmpdir}/t.cgi" + + ## check directory listing against an empty directory + ../bin/hio-webs "${srvaddr}" "${tmpdir}" 2>/dev/null & + local jid=$! + sleep 0.5 + + local hc=$(curl -s -w '%{http_code}\n' -o /dev/null "http://${srvaddr}/t.cgi?abc=def#qq") + tap_ensure "$hc" "200" "$msg - got $hc" + + rm -rf "${tmpdir}" + + kill -TERM ${jid} + wait ${jid} +} + test_default_index test_file_list_dir +test_cgi + tap_end diff --git a/t/t-cgi.c b/t/t-cgi.c new file mode 100644 index 0000000..a6ae6d8 --- /dev/null +++ b/t/t-cgi.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +int main () +{ + time_t current_time; + size_t i; + static const char* var[] = + { + "REQUEST_METHOD", + "REQUEST_URI", + "QUERY_STRING", + "REMOTE_ADDR", + "REMOTE_PORT", + "CONTENT_LENGTH" + }; + + printf("Content-type: text/plain\r\n\r\n"); + printf("C Program Version\n"); + current_time = time(NULL); + printf("It is now %s\n", ctime(¤t_time)); + + for (i = 0; i < sizeof(var) / sizeof(var[0]); i++) + { + printf ("%s:%s\n", var[i], getenv(var[i])); + } + + fflush(stdout); + exit (0); +}