removed many debugging messages from httpd
This commit is contained in:
		| @ -35,6 +35,7 @@ | |||||||
| #include <stdarg.h> | #include <stdarg.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <locale.h> | #include <locale.h> | ||||||
|  | #include <stdio.h> | ||||||
|  |  | ||||||
| #define ENABLE_CALLBACK | #define ENABLE_CALLBACK | ||||||
| #define ABORT(label) goto label | #define ABORT(label) goto label | ||||||
|  | |||||||
| @ -5,6 +5,10 @@ AM_CPPFLAGS = \ | |||||||
| 	-I$(top_srcdir)/include \ | 	-I$(top_srcdir)/include \ | ||||||
| 	-I$(includedir) | 	-I$(includedir) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | qsecfgdir = $(sysconfdir)/qse | ||||||
|  | qsecfg_DATA = httpd.conf httpd-mime.conf | ||||||
|  |  | ||||||
| bin_PROGRAMS = qsehttpd | bin_PROGRAMS = qsehttpd | ||||||
|  |  | ||||||
| qsehttpd_SOURCES = httpd.c | qsehttpd_SOURCES = httpd.c | ||||||
|  | |||||||
| @ -15,6 +15,7 @@ | |||||||
|  |  | ||||||
| @SET_MAKE@ | @SET_MAKE@ | ||||||
|  |  | ||||||
|  |  | ||||||
| VPATH = @srcdir@ | VPATH = @srcdir@ | ||||||
| pkgdatadir = $(datadir)/@PACKAGE@ | pkgdatadir = $(datadir)/@PACKAGE@ | ||||||
| pkgincludedir = $(includedir)/@PACKAGE@ | pkgincludedir = $(includedir)/@PACKAGE@ | ||||||
| @ -51,7 +52,7 @@ mkinstalldirs = $(install_sh) -d | |||||||
| CONFIG_HEADER = $(top_builddir)/include/qse/config.h | CONFIG_HEADER = $(top_builddir)/include/qse/config.h | ||||||
| CONFIG_CLEAN_FILES = | CONFIG_CLEAN_FILES = | ||||||
| CONFIG_CLEAN_VPATH_FILES = | CONFIG_CLEAN_VPATH_FILES = | ||||||
| am__installdirs = "$(DESTDIR)$(bindir)" | am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(qsecfgdir)" | ||||||
| PROGRAMS = $(bin_PROGRAMS) | PROGRAMS = $(bin_PROGRAMS) | ||||||
| am_qsehttpd_OBJECTS = httpd.$(OBJEXT) | am_qsehttpd_OBJECTS = httpd.$(OBJEXT) | ||||||
| qsehttpd_OBJECTS = $(am_qsehttpd_OBJECTS) | qsehttpd_OBJECTS = $(am_qsehttpd_OBJECTS) | ||||||
| @ -92,6 +93,34 @@ am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) | |||||||
| am__v_GEN_0 = @echo "  GEN   " $@; | am__v_GEN_0 = @echo "  GEN   " $@; | ||||||
| SOURCES = $(qsehttpd_SOURCES) | SOURCES = $(qsehttpd_SOURCES) | ||||||
| DIST_SOURCES = $(qsehttpd_SOURCES) | DIST_SOURCES = $(qsehttpd_SOURCES) | ||||||
|  | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; | ||||||
|  | am__vpath_adj = case $$p in \ | ||||||
|  |     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ | ||||||
|  |     *) f=$$p;; \ | ||||||
|  |   esac; | ||||||
|  | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; | ||||||
|  | am__install_max = 40 | ||||||
|  | am__nobase_strip_setup = \ | ||||||
|  |   srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` | ||||||
|  | am__nobase_strip = \ | ||||||
|  |   for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" | ||||||
|  | am__nobase_list = $(am__nobase_strip_setup); \ | ||||||
|  |   for p in $$list; do echo "$$p $$p"; done | \ | ||||||
|  |   sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ | ||||||
|  |   $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ | ||||||
|  |     if (++n[$$2] == $(am__install_max)) \ | ||||||
|  |       { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ | ||||||
|  |     END { for (dir in files) print dir, files[dir] }' | ||||||
|  | am__base_list = \ | ||||||
|  |   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ | ||||||
|  |   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | ||||||
|  | am__uninstall_files_from_dir = { \ | ||||||
|  |   test -z "$$files" \ | ||||||
|  |     || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ | ||||||
|  |     || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ | ||||||
|  |          $(am__cd) "$$dir" && rm -f $$files; }; \ | ||||||
|  |   } | ||||||
|  | DATA = $(qsecfg_DATA) | ||||||
| ETAGS = etags | ETAGS = etags | ||||||
| CTAGS = ctags | CTAGS = ctags | ||||||
| DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||||||
| @ -275,6 +304,8 @@ AM_CPPFLAGS = \ | |||||||
| 	-I$(top_srcdir)/include \ | 	-I$(top_srcdir)/include \ | ||||||
| 	-I$(includedir) | 	-I$(includedir) | ||||||
|  |  | ||||||
|  | qsecfgdir = $(sysconfdir)/qse | ||||||
|  | qsecfg_DATA = httpd.conf httpd-mime.conf | ||||||
| qsehttpd_SOURCES = httpd.c | qsehttpd_SOURCES = httpd.c | ||||||
| qsehttpd_LDFLAGS = -L../../lib/xli -L../../lib/http -L../../lib/cmn -L$(libdir) | qsehttpd_LDFLAGS = -L../../lib/xli -L../../lib/http -L../../lib/cmn -L$(libdir) | ||||||
| qsehttpd_LDADD = -lqsexli -lqsehttp -lqsecmn $(am__append_1) | qsehttpd_LDADD = -lqsexli -lqsehttp -lqsecmn $(am__append_1) | ||||||
| @ -393,6 +424,24 @@ mostlyclean-libtool: | |||||||
|  |  | ||||||
| clean-libtool: | clean-libtool: | ||||||
| 	-rm -rf .libs _libs | 	-rm -rf .libs _libs | ||||||
|  | install-qsecfgDATA: $(qsecfg_DATA) | ||||||
|  | 	@$(NORMAL_INSTALL) | ||||||
|  | 	test -z "$(qsecfgdir)" || $(MKDIR_P) "$(DESTDIR)$(qsecfgdir)" | ||||||
|  | 	@list='$(qsecfg_DATA)'; test -n "$(qsecfgdir)" || list=; \ | ||||||
|  | 	for p in $$list; do \ | ||||||
|  | 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ | ||||||
|  | 	  echo "$$d$$p"; \ | ||||||
|  | 	done | $(am__base_list) | \ | ||||||
|  | 	while read files; do \ | ||||||
|  | 	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(qsecfgdir)'"; \ | ||||||
|  | 	  $(INSTALL_DATA) $$files "$(DESTDIR)$(qsecfgdir)" || exit $$?; \ | ||||||
|  | 	done | ||||||
|  |  | ||||||
|  | uninstall-qsecfgDATA: | ||||||
|  | 	@$(NORMAL_UNINSTALL) | ||||||
|  | 	@list='$(qsecfg_DATA)'; test -n "$(qsecfgdir)" || list=; \ | ||||||
|  | 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ | ||||||
|  | 	dir='$(DESTDIR)$(qsecfgdir)'; $(am__uninstall_files_from_dir) | ||||||
|  |  | ||||||
| ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) | ||||||
| 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||||||
| @ -478,9 +527,9 @@ distdir: $(DISTFILES) | |||||||
| 	done | 	done | ||||||
| check-am: all-am | check-am: all-am | ||||||
| check: check-am | check: check-am | ||||||
| all-am: Makefile $(PROGRAMS) | all-am: Makefile $(PROGRAMS) $(DATA) | ||||||
| installdirs: | installdirs: | ||||||
| 	for dir in "$(DESTDIR)$(bindir)"; do \ | 	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(qsecfgdir)"; do \ | ||||||
| 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \ | 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \ | ||||||
| 	done | 	done | ||||||
| install: install-am | install: install-am | ||||||
| @ -535,7 +584,7 @@ info: info-am | |||||||
|  |  | ||||||
| info-am: | info-am: | ||||||
|  |  | ||||||
| install-data-am: | install-data-am: install-qsecfgDATA | ||||||
|  |  | ||||||
| install-dvi: install-dvi-am | install-dvi: install-dvi-am | ||||||
|  |  | ||||||
| @ -581,7 +630,7 @@ ps: ps-am | |||||||
|  |  | ||||||
| ps-am: | ps-am: | ||||||
|  |  | ||||||
| uninstall-am: uninstall-binPROGRAMS | uninstall-am: uninstall-binPROGRAMS uninstall-qsecfgDATA | ||||||
|  |  | ||||||
| .MAKE: install-am install-strip | .MAKE: install-am install-strip | ||||||
|  |  | ||||||
| @ -593,11 +642,11 @@ uninstall-am: uninstall-binPROGRAMS | |||||||
| 	install-dvi-am install-exec install-exec-am install-html \ | 	install-dvi-am install-exec install-exec-am install-html \ | ||||||
| 	install-html-am install-info install-info-am install-man \ | 	install-html-am install-info install-info-am install-man \ | ||||||
| 	install-pdf install-pdf-am install-ps install-ps-am \ | 	install-pdf install-pdf-am install-ps install-ps-am \ | ||||||
| 	install-strip installcheck installcheck-am installdirs \ | 	install-qsecfgDATA install-strip installcheck installcheck-am \ | ||||||
| 	maintainer-clean maintainer-clean-generic mostlyclean \ | 	installdirs maintainer-clean maintainer-clean-generic \ | ||||||
| 	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ | 	mostlyclean mostlyclean-compile mostlyclean-generic \ | ||||||
| 	pdf pdf-am ps ps-am tags uninstall uninstall-am \ | 	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ | ||||||
| 	uninstall-binPROGRAMS | 	uninstall-am uninstall-binPROGRAMS uninstall-qsecfgDATA | ||||||
|  |  | ||||||
|  |  | ||||||
| # Tell versions [3.59,3.63) of GNU make to not export all variables. | # Tell versions [3.59,3.63) of GNU make to not export all variables. | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ | |||||||
|  |  | ||||||
| #include <signal.h> | #include <signal.h> | ||||||
| #include <locale.h> | #include <locale.h> | ||||||
|  | #include <stdio.h> | ||||||
|  |  | ||||||
| #if defined(_WIN32) | #if defined(_WIN32) | ||||||
| #	include <winsock2.h> | #	include <winsock2.h> | ||||||
| @ -72,69 +73,57 @@ static void sig_reconf (int sig) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void setup_signal_handler (int signum, void(*handler)(int)) | ||||||
|  | { | ||||||
|  | #if defined(HAVE_SIGACTION) | ||||||
|  | 	struct sigaction act; | ||||||
|  | 	qse_memset (&act, 0, QSE_SIZEOF(act)); | ||||||
|  | 	act.sa_handler = handler; | ||||||
|  | 	sigaction (signum, &act, QSE_NULL); | ||||||
|  | #else | ||||||
|  | 	signal (signum, handler); | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  |  | ||||||
| static void setup_signal_handlers () | static void setup_signal_handlers () | ||||||
| { | { | ||||||
| 	struct sigaction act; |  | ||||||
|  |  | ||||||
| #if defined(SIGINT) | #if defined(SIGINT) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGINT, sig_stop); | ||||||
| 	act.sa_handler = sig_stop; |  | ||||||
| 	sigaction (SIGINT, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
| #if defined(SIGTERM) | #if defined(SIGTERM) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGTERM, sig_stop); | ||||||
| 	act.sa_handler = sig_stop; |  | ||||||
| 	sigaction (SIGTERM, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(SIGHUP) | #if defined(SIGHUP) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGHUP, sig_reconf); | ||||||
| 	act.sa_handler = sig_reconf; |  | ||||||
| 	sigaction (SIGHUP, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
| #if defined(SIGUSR1) | #if defined(SIGUSR1) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGUSR1, sig_reconf); | ||||||
| 	act.sa_handler = sig_reconf; |  | ||||||
| 	sigaction (SIGUSR1, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(SIGPIPE) | #if defined(SIGPIPE) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGPIPE, SIG_IGN); | ||||||
| 	act.sa_handler = SIG_IGN; |  | ||||||
| 	sigaction (SIGPIPE, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| static void restore_signal_handlers () | static void restore_signal_handlers () | ||||||
| { | { | ||||||
| 	struct sigaction act; |  | ||||||
|  |  | ||||||
| #if defined(SIGINT) | #if defined(SIGINT) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGINT, SIG_DFL); | ||||||
| 	act.sa_handler = SIG_DFL; |  | ||||||
| 	sigaction (SIGINT, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
| #if defined(SIGTERM) | #if defined(SIGTERM) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGTERM, SIG_DFL); | ||||||
| 	act.sa_handler = SIG_DFL; |  | ||||||
| 	sigaction (SIGTERM, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(SIGHUP) | #if defined(SIGHUP) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGHUP, SIG_DFL); | ||||||
| 	act.sa_handler = SIG_DFL; |  | ||||||
| 	sigaction (SIGHUP, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
| #if defined(SIGUSR1) | #if defined(SIGUSR1) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGUSR1, SIG_DFL); | ||||||
| 	act.sa_handler = SIG_DFL; |  | ||||||
| 	sigaction (SIGUSR1, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(SIGPIPE) | #if defined(SIGPIPE) | ||||||
| 	qse_memset (&act, 0, QSE_SIZEOF(act)); | 	setup_signal_handler (SIGPIPE, SIG_DFL); | ||||||
| 	act.sa_handler = SIG_DFL; |  | ||||||
| 	sigaction (SIGPIPE, &act, QSE_NULL); |  | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -192,6 +181,7 @@ enum | |||||||
| struct cgi_t | struct cgi_t | ||||||
| { | { | ||||||
| 	enum { | 	enum { | ||||||
|  | 		CGI_PREFIX, | ||||||
| 		CGI_SUFFIX, | 		CGI_SUFFIX, | ||||||
| 		CGI_NAME, | 		CGI_NAME, | ||||||
| 		CGI_MAX | 		CGI_MAX | ||||||
| @ -207,6 +197,7 @@ struct cgi_t | |||||||
| struct mime_t | struct mime_t | ||||||
| { | { | ||||||
| 	enum { | 	enum { | ||||||
|  | 		MIME_PREFIX, | ||||||
| 		MIME_SUFFIX, | 		MIME_SUFFIX, | ||||||
| 		MIME_NAME, | 		MIME_NAME, | ||||||
| 		MIME_OTHER, | 		MIME_OTHER, | ||||||
| @ -224,6 +215,7 @@ struct access_t | |||||||
| 	/* TODO: support more types like ACCESS_GLOB  | 	/* TODO: support more types like ACCESS_GLOB  | ||||||
| 	         not-only the base name, find a way to use query path or xpath */ | 	         not-only the base name, find a way to use query path or xpath */ | ||||||
| 	enum { | 	enum { | ||||||
|  | 		ACCESS_PREFIX, | ||||||
| 		ACCESS_SUFFIX, | 		ACCESS_SUFFIX, | ||||||
| 		ACCESS_NAME, | 		ACCESS_NAME, | ||||||
| 		ACCESS_OTHER, | 		ACCESS_OTHER, | ||||||
| @ -490,7 +482,8 @@ static int query_server ( | |||||||
| 				struct cgi_t* cgi; | 				struct cgi_t* cgi; | ||||||
| 				for (cgi = server_xtn->cgi[i].head; cgi; cgi = cgi->next) | 				for (cgi = server_xtn->cgi[i].head; cgi; cgi = cgi->next) | ||||||
| 				{ | 				{ | ||||||
| 					if ((cgi->type == CGI_SUFFIX && qse_mbsend (xpath_base, cgi->spec)) || | 					if ((cgi->type == CGI_PREFIX && qse_mbsbeg (xpath_base, cgi->spec)) || | ||||||
|  | 					    (cgi->type == CGI_SUFFIX && qse_mbsend (xpath_base, cgi->spec)) || | ||||||
| 					    (cgi->type == CGI_NAME && qse_mbscmp (xpath_base, cgi->spec) == 0)) | 					    (cgi->type == CGI_NAME && qse_mbscmp (xpath_base, cgi->spec) == 0)) | ||||||
| 					{ | 					{ | ||||||
| 						scgi->cgi = 1; | 						scgi->cgi = 1; | ||||||
| @ -517,7 +510,8 @@ static int query_server ( | |||||||
| 				struct mime_t* mime; | 				struct mime_t* mime; | ||||||
| 				for (mime = server_xtn->mime[i].head; mime; mime = mime->next) | 				for (mime = server_xtn->mime[i].head; mime; mime = mime->next) | ||||||
| 				{ | 				{ | ||||||
| 					if ((mime->type == MIME_SUFFIX && qse_mbsend (xpath_base, mime->spec)) || | 					if ((mime->type == MIME_PREFIX && qse_mbsbeg (xpath_base, mime->spec)) || | ||||||
|  | 					    (mime->type == MIME_SUFFIX && qse_mbsend (xpath_base, mime->spec)) || | ||||||
| 					    (mime->type == MIME_NAME && qse_mbscmp (xpath_base, mime->spec) == 0) || | 					    (mime->type == MIME_NAME && qse_mbscmp (xpath_base, mime->spec) == 0) || | ||||||
| 					    mime->type == MIME_OTHER) | 					    mime->type == MIME_OTHER) | ||||||
| 					{ | 					{ | ||||||
| @ -546,7 +540,8 @@ static int query_server ( | |||||||
| 				struct access_t* access; | 				struct access_t* access; | ||||||
| 				for (access = server_xtn->access[id][i].head; access; access = access->next) | 				for (access = server_xtn->access[id][i].head; access; access = access->next) | ||||||
| 				{ | 				{ | ||||||
| 					if ((access->type == ACCESS_SUFFIX && qse_mbsend (xpath_base, access->spec)) || | 					if ((access->type == ACCESS_PREFIX && qse_mbsbeg (xpath_base, access->spec)) || | ||||||
|  | 					    (access->type == ACCESS_SUFFIX && qse_mbsend (xpath_base, access->spec)) || | ||||||
| 					    (access->type == ACCESS_NAME && qse_mbscmp (xpath_base, access->spec) == 0) || | 					    (access->type == ACCESS_NAME && qse_mbscmp (xpath_base, access->spec) == 0) || | ||||||
| 					    access->type == ACCESS_OTHER) | 					    access->type == ACCESS_OTHER) | ||||||
| 					{ | 					{ | ||||||
| @ -645,14 +640,9 @@ static int load_server_config ( | |||||||
| 				struct cgi_t* cgi; | 				struct cgi_t* cgi; | ||||||
| 				int type; | 				int type; | ||||||
|  |  | ||||||
| 				if (qse_strcmp (pair->key, QSE_T("suffix")) == 0) | 				if (qse_strcmp (pair->key, QSE_T("prefix")) == 0) type = CGI_PREFIX; | ||||||
| 				{ | 				else if (qse_strcmp (pair->key, QSE_T("suffix")) == 0) type = CGI_SUFFIX; | ||||||
| 					type = CGI_SUFFIX; | 				else if (qse_strcmp (pair->key, QSE_T("name")) == 0) type = CGI_NAME; | ||||||
| 				} |  | ||||||
| 				else if (qse_strcmp (pair->key, QSE_T("name")) == 0) |  | ||||||
| 				{ |  | ||||||
| 					type = CGI_NAME; |  | ||||||
| 				} |  | ||||||
| 				else continue; | 				else continue; | ||||||
|  |  | ||||||
| 				cgi = qse_httpd_callocmem (httpd, QSE_SIZEOF(*cgi)); | 				cgi = qse_httpd_callocmem (httpd, QSE_SIZEOF(*cgi)); | ||||||
| @ -726,7 +716,8 @@ static int load_server_config ( | |||||||
| 				struct mime_t* mime; | 				struct mime_t* mime; | ||||||
| 				int type; | 				int type; | ||||||
|  |  | ||||||
| 				if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = MIME_SUFFIX; | 				if (qse_strcmp (pair->key, QSE_T("prefix")) == 0 && pair->name) type = MIME_PREFIX; | ||||||
|  | 				else if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = MIME_SUFFIX; | ||||||
| 				else if (qse_strcmp (pair->key, QSE_T("name")) == 0 && pair->name) type = MIME_NAME; | 				else if (qse_strcmp (pair->key, QSE_T("name")) == 0 && pair->name) type = MIME_NAME; | ||||||
| 				else if (qse_strcmp (pair->key, QSE_T("other")) == 0 && !pair->name) type = MIME_OTHER; | 				else if (qse_strcmp (pair->key, QSE_T("other")) == 0 && !pair->name) type = MIME_OTHER; | ||||||
| 				else continue; | 				else continue; | ||||||
| @ -793,7 +784,8 @@ static int load_server_config ( | |||||||
| 					const qse_char_t* tmp; | 					const qse_char_t* tmp; | ||||||
| 					int type, value; | 					int type, value; | ||||||
| 	 | 	 | ||||||
| 					if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = ACCESS_SUFFIX; | 					if (qse_strcmp (pair->key, QSE_T("prefix")) == 0 && pair->name) type = ACCESS_PREFIX; | ||||||
|  | 					else if (qse_strcmp (pair->key, QSE_T("suffix")) == 0 && pair->name) type = ACCESS_SUFFIX; | ||||||
| 					else if (qse_strcmp (pair->key, QSE_T("name")) == 0 && pair->name) type = ACCESS_NAME; | 					else if (qse_strcmp (pair->key, QSE_T("name")) == 0 && pair->name) type = ACCESS_NAME; | ||||||
| 					else if (qse_strcmp (pair->key, QSE_T("other")) == 0 && !pair->name) type = ACCESS_OTHER; | 					else if (qse_strcmp (pair->key, QSE_T("other")) == 0 && !pair->name) type = ACCESS_OTHER; | ||||||
| 					else continue; | 					else continue; | ||||||
|  | |||||||
| @ -17,9 +17,9 @@ default { | |||||||
| 	        "index.cgi"; | 	        "index.cgi"; | ||||||
|  |  | ||||||
| 	cgi { | 	cgi { | ||||||
| 		name "t3.nph" = "nph"; | 		#name "t3.nph" = "nph"; | ||||||
| 		suffix ".cgi"; | 		suffix ".cgi"; | ||||||
| 		suffix ".ant" = "nph", ""; | 		suffix ".nph" = "nph"; | ||||||
| 		suffix ".awk" = "cgi", "/usr/bin/qseawk -f"; | 		suffix ".awk" = "cgi", "/usr/bin/qseawk -f"; | ||||||
|  |  | ||||||
| 		# glob is not supported yet | 		# glob is not supported yet | ||||||
| @ -32,20 +32,22 @@ default { | |||||||
|  |  | ||||||
| 	# control access to directories | 	# control access to directories | ||||||
| 	dir-access { | 	dir-access { | ||||||
| 		# suffix ".xxxx" = ok; | 		#prefix ".xxxx" = ok; | ||||||
| 		# name "xxxxx" = ok; | 		#suffix ".xxxx" = ok; | ||||||
| 		other = noent; | 		#name "xxxxx" = ok; | ||||||
|  | 		#other = noent; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	# control access to normal files. | 	# control access to normal files. | ||||||
| 	# cgi scripts are not control by these. | 	# cgi scripts are not control by these. | ||||||
| 	file-access { | 	file-access { | ||||||
|  | 		#prefix "index.html." = ok; | ||||||
| 		suffix ".html" = ok; | 		suffix ".html" = ok; | ||||||
| 		suffix ".css" = ok; | 		suffix ".css" = ok; | ||||||
| 		suffix ".js" = ok; | 		suffix ".js" = ok; | ||||||
| 		suffix ".png" = ok; | 		suffix ".png" = ok; | ||||||
| 		suffix ".jpg" = ok; | 		suffix ".jpg" = ok; | ||||||
| 		other = noent; | 		#other = noent; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	dir-css = "<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; } table { font-size: 0.9em; } td { white-space: nowrap; } td.size { text-align: right; }</style>"; | 	dir-css = "<style type='text/css'>body { background-color:#d0e4fe; font-size: 0.9em; } div.header { font-weight: bold; margin-bottom: 5px; } div.footer { border-top: 1px solid #99AABB; text-align: right; } table { font-size: 0.9em; } td { white-space: nowrap; } td.size { text-align: right; }</style>"; | ||||||
|  | |||||||
| @ -33,6 +33,7 @@ | |||||||
| #include <qse/cmn/glob.h> | #include <qse/cmn/glob.h> | ||||||
|  |  | ||||||
| #include <locale.h> | #include <locale.h> | ||||||
|  | #include <stdio.h> | ||||||
|  |  | ||||||
| #if defined(_WIN32) | #if defined(_WIN32) | ||||||
| #	include <windows.h> | #	include <windows.h> | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								qse/configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								qse/configure
									
									
									
									
										vendored
									
									
								
							| @ -17618,6 +17618,18 @@ _ACEOF | |||||||
| fi | fi | ||||||
| done | done | ||||||
|  |  | ||||||
|  | for ac_func in _vsnprintf _vsnwprintf | ||||||
|  | do : | ||||||
|  |   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` | ||||||
|  | ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" | ||||||
|  | if eval test \"x\$"$as_ac_var"\" = x"yes"; then : | ||||||
|  |   cat >>confdefs.h <<_ACEOF | ||||||
|  | #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 | ||||||
|  | _ACEOF | ||||||
|  |  | ||||||
|  | fi | ||||||
|  | done | ||||||
|  |  | ||||||
|  |  | ||||||
| OLDLIBS="$LIBS" | OLDLIBS="$LIBS" | ||||||
| LIBS="$LIBM $LIBS" | LIBS="$LIBM $LIBS" | ||||||
|  | |||||||
| @ -136,6 +136,7 @@ AC_CHECK_FUNCS([backtrace backtrace_symbols]) | |||||||
| AC_CHECK_FUNCS([fdopendir]) | AC_CHECK_FUNCS([fdopendir]) | ||||||
| AC_CHECK_FUNCS([fork vfork posix_spawn gettid nanosleep select]) | AC_CHECK_FUNCS([fork vfork posix_spawn gettid nanosleep select]) | ||||||
| AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext]) | AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext]) | ||||||
|  | AC_CHECK_FUNCS([_vsnprintf _vsnwprintf]) | ||||||
|  |  | ||||||
| OLDLIBS="$LIBS" | OLDLIBS="$LIBS" | ||||||
| LIBS="$LIBM $LIBS" | LIBS="$LIBM $LIBS" | ||||||
|  | |||||||
| @ -568,6 +568,12 @@ | |||||||
| /* This value is set to 1 to indicate that the system argz facility works */ | /* This value is set to 1 to indicate that the system argz facility works */ | ||||||
| #undef HAVE_WORKING_ARGZ | #undef HAVE_WORKING_ARGZ | ||||||
|  |  | ||||||
|  | /* Define to 1 if you have the `_vsnprintf' function. */ | ||||||
|  | #undef HAVE__VSNPRINTF | ||||||
|  |  | ||||||
|  | /* Define to 1 if you have the `_vsnwprintf' function. */ | ||||||
|  | #undef HAVE__VSNWPRINTF | ||||||
|  |  | ||||||
| /* Define if the OS needs help to load dependent libraries for dlopen(). */ | /* Define if the OS needs help to load dependent libraries for dlopen(). */ | ||||||
| #undef LTDL_DLOPEN_DEPLIBS | #undef LTDL_DLOPEN_DEPLIBS | ||||||
|  |  | ||||||
|  | |||||||
| @ -106,7 +106,7 @@ enum qse_xli_atom_type_t | |||||||
| typedef enum qse_xli_atom_type_t qse_xli_atom_type_t; | typedef enum qse_xli_atom_type_t qse_xli_atom_type_t; | ||||||
|  |  | ||||||
| #define QSE_XLI_VAL_HDR \ | #define QSE_XLI_VAL_HDR \ | ||||||
| 	qse_xli_val_type_t type; | 	qse_xli_val_type_t type | ||||||
|  |  | ||||||
| struct qse_xli_val_t | struct qse_xli_val_t | ||||||
| { | { | ||||||
| @ -500,7 +500,7 @@ QSE_EXPORT qse_xli_pair_t* qse_xli_insertpairwithstr ( | |||||||
| ); | ); | ||||||
|  |  | ||||||
|  |  | ||||||
| qse_xli_pair_t* qse_xli_findpairbyname ( | QSE_EXPORT qse_xli_pair_t* qse_xli_findpairbyname ( | ||||||
|      qse_xli_t*            xli, |      qse_xli_t*            xli, | ||||||
| 	const qse_xli_list_t* list, | 	const qse_xli_list_t* list, | ||||||
| 	const qse_char_t*     name | 	const qse_char_t*     name | ||||||
|  | |||||||
| @ -161,13 +161,13 @@ int qse_vsprintf (qse_char_t* buf, qse_size_t size, const qse_char_t* fmt, va_li | |||||||
| 	if (nf == NULL) return -1; | 	if (nf == NULL) return -1; | ||||||
|  |  | ||||||
| #if defined(QSE_CHAR_IS_MCHAR) | #if defined(QSE_CHAR_IS_MCHAR) | ||||||
| 	#if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) | 	#if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) || defined(HAVE__VSNPRINTF) | ||||||
| 		n = _vsnprintf (buf, size, nf, ap); | 		n = _vsnprintf (buf, size, nf, ap); | ||||||
| 	#else | 	#else | ||||||
| 		n = vsnprintf (buf, size, nf, ap); | 		n = vsnprintf (buf, size, nf, ap); | ||||||
| 	#endif | 	#endif | ||||||
| #else | #else | ||||||
| 	#if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) | 	#if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) || defined(HAVE__VSNWPRINTF) | ||||||
| 		n = _vsnwprintf (buf, size, nf, ap); | 		n = _vsnwprintf (buf, size, nf, ap); | ||||||
| 	#else | 	#else | ||||||
| 		n = vswprintf (buf, size, nf, ap); | 		n = vswprintf (buf, size, nf, ap); | ||||||
|  | |||||||
| @ -24,8 +24,6 @@ | |||||||
| #include <qse/cmn/str.h> | #include <qse/cmn/str.h> | ||||||
| #include <qse/cmn/fmt.h> | #include <qse/cmn/fmt.h> | ||||||
|  |  | ||||||
| #include <stdio.h> /* TODO: remove this.*/ |  | ||||||
|  |  | ||||||
| typedef struct task_proxy_arg_t task_proxy_arg_t; | typedef struct task_proxy_arg_t task_proxy_arg_t; | ||||||
| struct task_proxy_arg_t  | struct task_proxy_arg_t  | ||||||
| { | { | ||||||
| @ -96,6 +94,17 @@ struct proxy_peer_htrd_xtn_t | |||||||
| 	qse_httpd_task_t* task; | 	qse_httpd_task_t* task; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | static void log_proxy_error (task_proxy_t* proxy, const qse_mchar_t* shortmsg) | ||||||
|  | { | ||||||
|  | 	qse_httpd_act_t msg; | ||||||
|  | 	qse_size_t pos = 0; | ||||||
|  |  | ||||||
|  | 	msg.code = QSE_HTTPD_CATCH_MERRMSG; | ||||||
|  | 	pos += qse_mbsxcpy (&msg.u.merrmsg[pos], QSE_COUNTOF(msg.u.merrmsg) - pos, shortmsg); | ||||||
|  | 	pos += qse_nwadtombs (&proxy->peer.nwad, &msg.u.merrmsg[pos], QSE_COUNTOF(msg.u.merrmsg) - pos, QSE_NWADTOMBS_ALL); | ||||||
|  | 	proxy->httpd->opt.rcb.logact (proxy->httpd, &msg); | ||||||
|  | } | ||||||
|  |  | ||||||
| static int proxy_add_header_to_buffer ( | static int proxy_add_header_to_buffer ( | ||||||
| 	task_proxy_t* proxy, qse_mbs_t* buf, const qse_mchar_t* key, const qse_htre_hdrval_t* val) | 	task_proxy_t* proxy, qse_mbs_t* buf, const qse_mchar_t* key, const qse_htre_hdrval_t* val) | ||||||
| { | { | ||||||
| @ -182,8 +191,10 @@ static int proxy_snatch_client_input ( | |||||||
| 	task = (qse_httpd_task_t*)ctx; | 	task = (qse_httpd_task_t*)ctx; | ||||||
| 	proxy = (task_proxy_t*)task->ctx; | 	proxy = (task_proxy_t*)task->ctx; | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| if (ptr) qse_printf (QSE_T("!!!PROXY SNATCHING [%.*hs]\n"), len, ptr); | if (ptr) qse_printf (QSE_T("!!!PROXY SNATCHING [%.*hs]\n"), len, ptr); | ||||||
| else qse_printf (QSE_T("!!!PROXY SNATCHING DONE\n")); | else qse_printf (QSE_T("!!!PROXY SNATCHING DONE\n")); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (ptr == QSE_NULL) | 	if (ptr == QSE_NULL) | ||||||
| 	{ | 	{ | ||||||
| @ -260,7 +271,9 @@ else qse_printf (QSE_T("!!!PROXY SNATCHING DONE\n")); | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		task->trigger[0].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | 		task->trigger[0].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("!!!PROXY SNATCHED [%.*hs]\n"), len, ptr); | qse_printf (QSE_T("!!!PROXY SNATCHED [%.*hs]\n"), len, ptr); | ||||||
|  | #endif | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return 0; | 	return 0; | ||||||
| @ -295,7 +308,9 @@ static int proxy_snatch_peer_output ( | |||||||
|  |  | ||||||
| 		QSE_ASSERT (len == 0); | 		QSE_ASSERT (len == 0); | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("PROXY GOT ALL RESPONSE>>>>>>>\n")); | qse_printf (QSE_T("PROXY GOT ALL RESPONSE>>>>>>>\n")); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 		if (qse_mbs_cat (proxy->res, QSE_MT("0\r\n")) == (qse_size_t)-1 || | 		if (qse_mbs_cat (proxy->res, QSE_MT("0\r\n")) == (qse_size_t)-1 || | ||||||
| 		    qse_htre_walktrailers (req, proxy_capture_peer_trailer, proxy) <= -1 || | 		    qse_htre_walktrailers (req, proxy_capture_peer_trailer, proxy) <= -1 || | ||||||
| @ -352,8 +367,9 @@ static int proxy_htrd_peek_peer_output (qse_htrd_t* htrd, qse_htre_t* res) | |||||||
|  |  | ||||||
| 	if ((proxy->resflags & PROXY_RES_AWAIT_100) && qse_htre_getscodeval(res) == 100) | 	if ((proxy->resflags & PROXY_RES_AWAIT_100) && qse_htre_getscodeval(res) == 100) | ||||||
| 	{ | 	{ | ||||||
| /* TODO: check if the request contained Expect... */ | 		/* TODO: check if the request contained Expect... */ | ||||||
| qse_printf (QSE_T("10000000000000000000000000000 CONTINUE 10000000000000000000000000000000\n")); |  | ||||||
|  | 		/* 100 continue */ | ||||||
| 		proxy->resflags &= ~PROXY_RES_AWAIT_100; | 		proxy->resflags &= ~PROXY_RES_AWAIT_100; | ||||||
| 		proxy->resflags |= PROXY_RES_RECEIVED_100; | 		proxy->resflags |= PROXY_RES_RECEIVED_100; | ||||||
|  |  | ||||||
| @ -381,7 +397,9 @@ qse_printf (QSE_T("10000000000000000000000000000 CONTINUE 1000000000000000000000 | |||||||
| 		proxy->resflags &= ~PROXY_RES_AWAIT_RESHDR; | 		proxy->resflags &= ~PROXY_RES_AWAIT_RESHDR; | ||||||
| 		proxy->resflags |= PROXY_RES_RECEIVED_RESHDR; | 		proxy->resflags |= PROXY_RES_RECEIVED_RESHDR; | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY\n")); | qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY\n")); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 		keepalive = proxy->keepalive; | 		keepalive = proxy->keepalive; | ||||||
| 		if (res->attr.flags & QSE_HTRE_ATTR_LENGTH) | 		if (res->attr.flags & QSE_HTRE_ATTR_LENGTH) | ||||||
| @ -521,8 +539,9 @@ qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY\n")); | |||||||
| 		if ((proxy->resflags & PROXY_RES_PEER_LENGTH) &&  | 		if ((proxy->resflags & PROXY_RES_PEER_LENGTH) &&  | ||||||
| 		    proxy->peer_output_received > proxy->peer_output_length) | 		    proxy->peer_output_received > proxy->peer_output_length) | ||||||
| 		{ | 		{ | ||||||
| 			/* TODO: logging?? */ | 			if (proxy->httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
| qse_printf (QSE_T("PROXY PEER FUCKED - RETURNING TOO MUCH...\n")); | 				log_proxy_error (proxy, "proxy redundant output - "); | ||||||
|  |  | ||||||
| 			proxy->httpd->errnum = QSE_HTTPD_EINVAL; /* TODO: change it to a better error code */ | 			proxy->httpd->errnum = QSE_HTTPD_EINVAL; /* TODO: change it to a better error code */ | ||||||
| 			return -1; | 			return -1; | ||||||
| 		} | 		} | ||||||
| @ -565,7 +584,9 @@ qse_printf (QSE_T("PROXY PEER FUCKED - RETURNING TOO MUCH...\n")); | |||||||
| 			/* arrange to store further contents received to proxy->res */ | 			/* arrange to store further contents received to proxy->res */ | ||||||
| 			qse_htre_setconcb (res, proxy_snatch_peer_output, xtn->task); | 			qse_htre_setconcb (res, proxy_snatch_peer_output, xtn->task); | ||||||
| 		} | 		} | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY OK\n")); | qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY OK\n")); | ||||||
|  | #endif | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	proxy->res_pending = QSE_MBS_LEN(proxy->res) - proxy->res_consumed; | 	proxy->res_pending = QSE_MBS_LEN(proxy->res) - proxy->res_consumed; | ||||||
| @ -574,7 +595,7 @@ qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY OK\n")); | |||||||
|  |  | ||||||
| static int proxy_htrd_handle_peer_output (qse_htrd_t* htrd, qse_htre_t* req) | static int proxy_htrd_handle_peer_output (qse_htrd_t* htrd, qse_htre_t* req) | ||||||
| { | { | ||||||
| qse_printf (QSE_T("FINISHED READING RESPONSE...\n")); | 	/* finished reading response from the peer */ | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -599,7 +620,6 @@ static void proxy_forward_client_input_to_peer ( | |||||||
| 		{ | 		{ | ||||||
| 			/* a forwarding error has occurred previously. | 			/* a forwarding error has occurred previously. | ||||||
| 			 * clear the forwarding buffer */ | 			 * clear the forwarding buffer */ | ||||||
| qse_printf (QSE_T("FORWARD: CLEARING REQCON FOR ERROR\n")); |  | ||||||
| 			qse_mbs_clear (proxy->reqfwdbuf); | 			qse_mbs_clear (proxy->reqfwdbuf); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| @ -610,14 +630,18 @@ qse_printf (QSE_T("FORWARD: CLEARING REQCON FOR ERROR\n")); | |||||||
| 			if (writable) goto forward; | 			if (writable) goto forward; | ||||||
|  |  | ||||||
| 			n = httpd->opt.scb.mux.writable (httpd, proxy->peer.handle, 0); | 			n = httpd->opt.scb.mux.writable (httpd, proxy->peer.handle, 0); | ||||||
|  | #if 0 | ||||||
| if (n == 0) qse_printf (QSE_T("PROXY FORWARD: @@@@@@@@@NOT WRITABLE\n")); | if (n == 0) qse_printf (QSE_T("PROXY FORWARD: @@@@@@@@@NOT WRITABLE\n")); | ||||||
|  | #endif | ||||||
| 			if (n >= 1) | 			if (n >= 1) | ||||||
| 			{ | 			{ | ||||||
| 			forward: | 			forward: | ||||||
| 				/* writable */ | 				/* writable */ | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("PROXY FORWARD: @@@@@@@@@@WRITING[%.*hs]\n"), | qse_printf (QSE_T("PROXY FORWARD: @@@@@@@@@@WRITING[%.*hs]\n"), | ||||||
| 	(int)QSE_MBS_LEN(proxy->reqfwdbuf), | 	(int)QSE_MBS_LEN(proxy->reqfwdbuf), | ||||||
| 	QSE_MBS_PTR(proxy->reqfwdbuf)); | 	QSE_MBS_PTR(proxy->reqfwdbuf)); | ||||||
|  | #endif | ||||||
| 				n = httpd->opt.scb.peer.send ( | 				n = httpd->opt.scb.peer.send ( | ||||||
| 					httpd, &proxy->peer, | 					httpd, &proxy->peer, | ||||||
| 					QSE_MBS_PTR(proxy->reqfwdbuf), | 					QSE_MBS_PTR(proxy->reqfwdbuf), | ||||||
| @ -639,8 +663,9 @@ to the head all the time..  grow the buffer to a certain limit. */ | |||||||
|  |  | ||||||
| 			if (n <= -1) | 			if (n <= -1) | ||||||
| 			{ | 			{ | ||||||
| qse_printf (QSE_T("PROXY FORWARD: @@@@@@@@WRITE TO PROXY FAILED\n")); | 				if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
| /* TODO: logging ... */ | 					log_proxy_error (proxy, "proxy send-to-peer error - "); | ||||||
|  |  | ||||||
| 				proxy->reqflags |= PROXY_REQ_FWDERR; | 				proxy->reqflags |= PROXY_REQ_FWDERR; | ||||||
| 				qse_mbs_clear (proxy->reqfwdbuf);  | 				qse_mbs_clear (proxy->reqfwdbuf);  | ||||||
| 				if (proxy->req)  | 				if (proxy->req)  | ||||||
| @ -662,7 +687,6 @@ qse_printf (QSE_T("PROXY FORWARD: @@@@@@@@WRITE TO PROXY FAILED\n")); | |||||||
| 		 * there is nothing more to forward in the forwarding buffer. | 		 * there is nothing more to forward in the forwarding buffer. | ||||||
| 		 * clear the read and write triggers. | 		 * clear the read and write triggers. | ||||||
| 		 */ | 		 */ | ||||||
| qse_printf (QSE_T("FORWARD: @@@@@@@@NOTHING MORE TO WRITE TO PROXY\n")); |  | ||||||
| 		task->trigger[0].mask &= ~QSE_HTTPD_TASK_TRIGGER_WRITE; /* peer */ | 		task->trigger[0].mask &= ~QSE_HTTPD_TASK_TRIGGER_WRITE; /* peer */ | ||||||
| 		task->trigger[2].mask = 0; /* client-side */ | 		task->trigger[2].mask = 0; /* client-side */ | ||||||
| 	} | 	} | ||||||
| @ -696,8 +720,8 @@ static int task_init_proxy ( | |||||||
|  * TODO: also change the content length check logic below... |  * TODO: also change the content length check logic below... | ||||||
|  * -------------------------------------------------------------------- */ |  * -------------------------------------------------------------------- */ | ||||||
|  |  | ||||||
| /* TODO: DETERMINE THIS SIZE */ | 	/* TODO: DETERMINE THIS SIZE */ | ||||||
| len = 1024; | 	len = 2048; | ||||||
|  |  | ||||||
| 	proxy->reqfwdbuf = qse_mbs_open (httpd->mmgr, 0, (len < 512? 512: len)); | 	proxy->reqfwdbuf = qse_mbs_open (httpd->mmgr, 0, (len < 512? 512: len)); | ||||||
| 	if (proxy->reqfwdbuf == QSE_NULL) goto oops; | 	if (proxy->reqfwdbuf == QSE_NULL) goto oops; | ||||||
| @ -845,7 +869,9 @@ len = 1024; | |||||||
| 	 * triggers in the task initializer. however the main task handler | 	 * triggers in the task initializer. however the main task handler | ||||||
| 	 * will be invoked so long as the client handle is writable by | 	 * will be invoked so long as the client handle is writable by | ||||||
| 	 * the main loop. */ | 	 * the main loop. */ | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("GOING TO PROXY [%hs]\n"), QSE_MBS_PTR(proxy->reqfwdbuf)); | qse_printf (QSE_T("GOING TO PROXY [%hs]\n"), QSE_MBS_PTR(proxy->reqfwdbuf)); | ||||||
|  | #endif | ||||||
| 	task->ctx = proxy; | 	task->ctx = proxy; | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
| @ -885,8 +911,10 @@ static int task_main_proxy_5 ( | |||||||
| 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | ||||||
| 	qse_ssize_t n; | 	qse_ssize_t n; | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("task_main_proxy_5 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | qse_printf (QSE_T("task_main_proxy_5 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | ||||||
| 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | ||||||
| 	{ | 	{ | ||||||
| @ -904,13 +932,14 @@ qse_printf (QSE_T("task_main_proxy_5 trigger[0].mask=%d trigger[1].mask=%d trigg | |||||||
| 	{ | 	{ | ||||||
| 		if (proxy->buflen > 0) | 		if (proxy->buflen > 0) | ||||||
| 		{ | 		{ | ||||||
| /* TODO: check if proxy outputs more than content-length if it is set... */ | 			/* TODO: check if proxy outputs more than content-length if it is set... */ | ||||||
| 			httpd->errnum = QSE_HTTPD_ENOERR; |  | ||||||
| 			n = httpd->opt.scb.client.send (httpd, client, proxy->buf, proxy->buflen); | 			n = httpd->opt.scb.client.send (httpd, client, proxy->buf, proxy->buflen); | ||||||
| 			if (n <= -1) | 			if (n <= -1) | ||||||
| 			{ | 			{ | ||||||
| 				/* can't return internal server error any more... */ | 				/* can't return internal server error any more... */ | ||||||
| /* TODO: logging ... */ | 				if (proxy->httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 					log_proxy_error (proxy, "proxy send-to-client error - "); | ||||||
| 				return -1; | 				return -1; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @ -931,8 +960,10 @@ static int task_main_proxy_4 ( | |||||||
| { | { | ||||||
| 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | ||||||
| 	 | 	 | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("task_main_proxy_4 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | qse_printf (QSE_T("task_main_proxy_4 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | ||||||
| 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | ||||||
| 	{ | 	{ | ||||||
| @ -943,25 +974,25 @@ qse_printf (QSE_T("task_main_proxy_4 trigger[0].mask=%d trigger[1].mask=%d trigg | |||||||
| 		proxy_forward_client_input_to_peer (httpd, task, 1); | 		proxy_forward_client_input_to_peer (httpd, task, 1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| qse_printf (QSE_T("task_main_proxy_4 about to read from PEER...\n")); |  | ||||||
| 	if (task->trigger[0].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | 	if (task->trigger[0].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | ||||||
| 	{ | 	{ | ||||||
| 		qse_ssize_t n; | 		qse_ssize_t n; | ||||||
|  |  | ||||||
| 		if (proxy->buflen < QSE_SIZEOF(proxy->buf)) | 		if (proxy->buflen < QSE_SIZEOF(proxy->buf)) | ||||||
| 		{ | 		{ | ||||||
| qse_printf (QSE_T("task_main_proxy_4 reading from PEER... %d %d\n"), (int)proxy->peer_output_length, (int)proxy->peer_output_received); | 			/* reading from the peer */ | ||||||
|  |  | ||||||
| 			httpd->errnum = QSE_HTTPD_ENOERR; | 			httpd->errnum = QSE_HTTPD_ENOERR; | ||||||
| 			n = httpd->opt.scb.peer.recv ( | 			n = httpd->opt.scb.peer.recv ( | ||||||
| 				httpd, &proxy->peer, | 				httpd, &proxy->peer, | ||||||
| 				&proxy->buf[proxy->buflen],  | 				&proxy->buf[proxy->buflen],  | ||||||
| 				QSE_SIZEOF(proxy->buf) - proxy->buflen | 				QSE_SIZEOF(proxy->buf) - proxy->buflen | ||||||
| 			); | 			); | ||||||
| qse_printf (QSE_T("task_main_proxy_4 read from PEER...%d\n"), (int)n); |  | ||||||
| 			if (n <= -1) | 			if (n <= -1) | ||||||
| 			{ | 			{ | ||||||
| 				/* can't return internal server error any more... */ | 				/* can't return internal server error any more... */ | ||||||
| 	/* TODO: loggig ... */ | 				if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 					log_proxy_error (proxy, "proxy recv-from-peer error - "); | ||||||
| 				return -1; | 				return -1; | ||||||
| 			} | 			} | ||||||
| 			if (n == 0) | 			if (n == 0) | ||||||
| @ -970,7 +1001,8 @@ qse_printf (QSE_T("task_main_proxy_4 read from PEER...%d\n"), (int)n); | |||||||
| 				{ | 				{ | ||||||
| 					if (proxy->peer_output_received < proxy->peer_output_length) | 					if (proxy->peer_output_received < proxy->peer_output_length) | ||||||
| 					{ | 					{ | ||||||
| 	qse_printf (QSE_T("PROXY FUCKED UP...PEER CLOSING PREMATURELY\n")); | 						if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 							log_proxy_error (proxy, "proxy premature eof - "); | ||||||
| 						return -1; | 						return -1; | ||||||
| 					} | 					} | ||||||
| 				}	 | 				}	 | ||||||
| @ -988,13 +1020,14 @@ qse_printf (QSE_T("task_main_proxy_4 read from PEER...%d\n"), (int)n); | |||||||
| 			{ | 			{ | ||||||
| 				if (proxy->peer_output_received > proxy->peer_output_length) | 				if (proxy->peer_output_received > proxy->peer_output_length) | ||||||
| 				{ | 				{ | ||||||
| 	/* TODO: proxy returning too much data... something is wrong in PROXY */ | 					/* proxy returning too much data... something is wrong in PROXY */ | ||||||
| 	qse_printf (QSE_T("PROXY FUCKED UP...RETURNING TOO MUCH DATA\n")); | 					if (proxy->httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 						log_proxy_error (proxy, "proxy redundant output - "); | ||||||
| 					return -1; | 					return -1; | ||||||
| 				} | 				} | ||||||
| 				else if (proxy->peer_output_received == proxy->peer_output_length) | 				else if (proxy->peer_output_received == proxy->peer_output_length) | ||||||
| 				{ | 				{ | ||||||
| 	qse_printf (QSE_T("PROXY DONE READING\n")); | 					/* proxy has finished reading all */ | ||||||
| 					task->main = task_main_proxy_5; | 					task->main = task_main_proxy_5; | ||||||
| 					task->trigger[0].mask = 0; | 					task->trigger[0].mask = 0; | ||||||
| 					task->trigger[2].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | 					task->trigger[2].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | ||||||
| @ -1006,13 +1039,12 @@ qse_printf (QSE_T("task_main_proxy_4 read from PEER...%d\n"), (int)n); | |||||||
| 		/* the main loop invokes the task function only if the client  | 		/* the main loop invokes the task function only if the client  | ||||||
| 		 * side is writable. it should be safe to write whenever | 		 * side is writable. it should be safe to write whenever | ||||||
| 		 * this task function is called. */ | 		 * this task function is called. */ | ||||||
| 		httpd->errnum = QSE_HTTPD_ENOERR; |  | ||||||
| 		n = httpd->opt.scb.client.send (httpd, client, proxy->buf, proxy->buflen); | 		n = httpd->opt.scb.client.send (httpd, client, proxy->buf, proxy->buflen); | ||||||
| 		if (n <= -1) | 		if (n <= -1) | ||||||
| 		{ | 		{ | ||||||
| 			/* can't return internal server error any more... */ | 			/* can't return internal server error any more... */ | ||||||
| 	/* TODO: logging ... */ | 			if (proxy->httpd->opt.trait & QSE_HTTPD_LOGACT) | ||||||
| 	qse_printf (QSE_T("CGI SEND FAILURE\n")); | 				log_proxy_error (proxy, "proxy send-to-client error - "); | ||||||
| 			return -1; | 			return -1; | ||||||
| 		} | 		} | ||||||
| 	 | 	 | ||||||
| @ -1033,8 +1065,10 @@ static int task_main_proxy_3 ( | |||||||
|  |  | ||||||
| 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | ||||||
|  |  | ||||||
|  | #if  0 | ||||||
| qse_printf (QSE_T("task_main_proxy_3 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | qse_printf (QSE_T("task_main_proxy_3 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | ||||||
| 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | ||||||
| 	{ | 	{ | ||||||
| @ -1051,23 +1085,20 @@ qse_printf (QSE_T("task_main_proxy_3 trigger[0].mask=%d trigger[1].mask=%d trigg | |||||||
| 		qse_ssize_t n; | 		qse_ssize_t n; | ||||||
| 		qse_size_t count; | 		qse_size_t count; | ||||||
|  |  | ||||||
| qse_printf (QSE_T("[PROXY-----3 SENDING XXXXX]\n")); |  | ||||||
| 		count = proxy->res_pending; | 		count = proxy->res_pending; | ||||||
| 		if (count > MAX_SEND_SIZE) count = MAX_SEND_SIZE; | 		if (count > MAX_SEND_SIZE) count = MAX_SEND_SIZE; | ||||||
|  |  | ||||||
| 		if (count > 0) | 		if (count > 0) | ||||||
| 		{ | 		{ | ||||||
| qse_printf (QSE_T("[proxy_3 sending %d bytes]\n"), (int)count); |  | ||||||
| 			httpd->errnum = QSE_HTTPD_ENOERR; |  | ||||||
| 			n = httpd->opt.scb.client.send ( | 			n = httpd->opt.scb.client.send ( | ||||||
| 				httpd, client,  | 				httpd, client,  | ||||||
| 				&QSE_MBS_CHAR(proxy->res,proxy->res_consumed),  | 				&QSE_MBS_CHAR(proxy->res,proxy->res_consumed),  | ||||||
| 				count | 				count | ||||||
| 			); | 			); | ||||||
|  |  | ||||||
| 			if (n <= -1)  | 			if (n <= -1)  | ||||||
| 			{ | 			{ | ||||||
| qse_printf (QSE_T("[proxy-3 send failure....\n")); | 				if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 					log_proxy_error (proxy, "proxy send-to-client error - "); | ||||||
| 				return -1; | 				return -1; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @ -1084,15 +1115,19 @@ qse_printf (QSE_T("[proxy-3 send failure....\n")); | |||||||
| 			if ((proxy->resflags & PROXY_RES_CLIENT_CHUNK) || | 			if ((proxy->resflags & PROXY_RES_CLIENT_CHUNK) || | ||||||
| 			    ((proxy->resflags & PROXY_RES_PEER_LENGTH) && proxy->peer_output_received >= proxy->peer_output_length)) | 			    ((proxy->resflags & PROXY_RES_PEER_LENGTH) && proxy->peer_output_received >= proxy->peer_output_length)) | ||||||
| 			{ | 			{ | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("SWITINCG TO 55555555555555555555555555 %d %d %d %d\n"),  | qse_printf (QSE_T("SWITINCG TO 55555555555555555555555555 %d %d %d %d\n"),  | ||||||
| 	(proxy->resflags & PROXY_RES_CLIENT_CHUNK), (proxy->resflags & PROXY_RES_PEER_LENGTH), | 	(proxy->resflags & PROXY_RES_CLIENT_CHUNK), (proxy->resflags & PROXY_RES_PEER_LENGTH), | ||||||
| 	(int)proxy->peer_output_received, (int)proxy->peer_output_length); | 	(int)proxy->peer_output_received, (int)proxy->peer_output_length); | ||||||
|  | #endif | ||||||
| 				task->main = task_main_proxy_5; | 				task->main = task_main_proxy_5; | ||||||
| 				task->trigger[2].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | 				task->trigger[2].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("SWITICHING TO 4444444444444444444444444444\n")); | qse_printf (QSE_T("SWITICHING TO 4444444444444444444444444444\n")); | ||||||
|  | #endif | ||||||
| 				task->main = task_main_proxy_4; | 				task->main = task_main_proxy_4; | ||||||
| 				task->trigger[2].mask &= ~QSE_HTTPD_TASK_TRIGGER_WRITE; | 				task->trigger[2].mask &= ~QSE_HTTPD_TASK_TRIGGER_WRITE; | ||||||
| 			} | 			} | ||||||
| @ -1109,8 +1144,10 @@ static int task_main_proxy_2 ( | |||||||
| 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | 	task_proxy_t* proxy = (task_proxy_t*)task->ctx; | ||||||
| 	int http_errnum = 500; | 	int http_errnum = 500; | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("task_main_proxy_2 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | qse_printf (QSE_T("task_main_proxy_2 trigger[0].mask=%d trigger[1].mask=%d trigger[2].mask=%d\n"),  | ||||||
| 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | 	task->trigger[0].mask, task->trigger[1].mask, task->trigger[2].mask); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | 	if (task->trigger[2].mask & QSE_HTTPD_TASK_TRIGGER_READABLE) | ||||||
| 	{ | 	{ | ||||||
| @ -1143,6 +1180,7 @@ qse_printf (QSE_T("task_main_proxy_2 trigger[0].mask=%d trigger[1].mask=%d trigg | |||||||
| 			count = proxy->res_pending; | 			count = proxy->res_pending; | ||||||
| 			if (count > MAX_SEND_SIZE) count = MAX_SEND_SIZE; | 			if (count > MAX_SEND_SIZE) count = MAX_SEND_SIZE; | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("[proxy_2 sending %d bytes (index %d)] ["),  | qse_printf (QSE_T("[proxy_2 sending %d bytes (index %d)] ["),  | ||||||
| 	(int)count, (int)proxy->res_consumed); | 	(int)count, (int)proxy->res_consumed); | ||||||
| { | { | ||||||
| @ -1150,8 +1188,8 @@ int i; | |||||||
| for (i = 0; i < count; i++) qse_printf (QSE_T("%hc"), QSE_MBS_CHAR(proxy->res,proxy->res_consumed+i)); | for (i = 0; i < count; i++) qse_printf (QSE_T("%hc"), QSE_MBS_CHAR(proxy->res,proxy->res_consumed+i)); | ||||||
| } | } | ||||||
| qse_printf (QSE_T("]\n")); | qse_printf (QSE_T("]\n")); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 			httpd->errnum = QSE_HTTPD_ENOERR; |  | ||||||
| 			n = httpd->opt.scb.client.send ( | 			n = httpd->opt.scb.client.send ( | ||||||
| 				httpd, client,  | 				httpd, client,  | ||||||
| 				QSE_MBS_CPTR(proxy->res,proxy->res_consumed),  | 				QSE_MBS_CPTR(proxy->res,proxy->res_consumed),  | ||||||
| @ -1159,7 +1197,8 @@ qse_printf (QSE_T("]\n")); | |||||||
| 			); | 			); | ||||||
| 			if (n <= -1)  | 			if (n <= -1)  | ||||||
| 			{ | 			{ | ||||||
| qse_printf (QSE_T("[proxy-2 send failure....\n")); | 				if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 					log_proxy_error (proxy, "proxy send-to-client error - "); | ||||||
| 				goto oops; | 				goto oops; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @ -1190,7 +1229,8 @@ qse_printf (QSE_T("[proxy-2 send failure....\n")); | |||||||
| 		); | 		); | ||||||
| 		if (n <= -1) | 		if (n <= -1) | ||||||
| 		{ | 		{ | ||||||
| /* TODO: logging ... */ | 			if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 				log_proxy_error (proxy, "proxy recv-from-peer error - "); | ||||||
| 			goto oops; | 			goto oops; | ||||||
| 		} | 		} | ||||||
| 		if (n == 0)  | 		if (n == 0)  | ||||||
| @ -1198,9 +1238,11 @@ qse_printf (QSE_T("[proxy-2 send failure....\n")); | |||||||
| 			if (!(proxy->resflags & PROXY_RES_RECEIVED_RESHDR)) | 			if (!(proxy->resflags & PROXY_RES_RECEIVED_RESHDR)) | ||||||
| 			{ | 			{ | ||||||
| 				/* end of output from peer before it has seen a header. | 				/* end of output from peer before it has seen a header. | ||||||
| 				 * the proxy script must be crooked. */ | 				 * the proxy peer must be crooked. */ | ||||||
| /* TODO: logging */ |  | ||||||
| qse_printf (QSE_T("#####PREMATURE EOF FROM PEER\n")); | 				if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 					log_proxy_error (proxy, "proxy premature eof - "); | ||||||
|  |  | ||||||
| 				if (!(proxy->resflags & PROXY_RES_RECEIVED_100)) http_errnum = 502; | 				if (!(proxy->resflags & PROXY_RES_RECEIVED_100)) http_errnum = 502; | ||||||
| 				goto oops; | 				goto oops; | ||||||
| 			} | 			} | ||||||
| @ -1219,24 +1261,28 @@ qse_printf (QSE_T("#####PREMATURE EOF FROM PEER\n")); | |||||||
| 					return 1; | 					return 1; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| qse_printf (QSE_T("#####PREMATURE EOF FROM PEER CLIENT CHUNK\n")); | 				/* premature eof from the peer */ | ||||||
|  | 				if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 					log_proxy_error (proxy, "proxy premature eof - "); | ||||||
| 				goto oops; | 				goto oops; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 			 | 			 | ||||||
| 		proxy->buflen += n; | 		proxy->buflen += n; | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("#####PROXY FEEDING %d [\n"), (int)proxy->buflen); | qse_printf (QSE_T("#####PROXY FEEDING %d [\n"), (int)proxy->buflen); | ||||||
| { | { | ||||||
| int i; | int i; | ||||||
| for (i = 0; i < proxy->buflen; i++) qse_printf (QSE_T("%hc"), proxy->buf[i]); | for (i = 0; i < proxy->buflen; i++) qse_printf (QSE_T("%hc"), proxy->buf[i]); | ||||||
| } | } | ||||||
| qse_printf (QSE_T("]\n")); | qse_printf (QSE_T("]\n")); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 		if (qse_htrd_feed (proxy->peer_htrd, proxy->buf, proxy->buflen) <= -1) | 		if (qse_htrd_feed (proxy->peer_htrd, proxy->buf, proxy->buflen) <= -1) | ||||||
| 		{ | 		{ | ||||||
| /* TODO: logging */ | 			if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
| qse_printf (QSE_T("#####INVALID HEADER FROM PEER [%.*hs]\n"), (int)proxy->buflen, proxy->buf); | 				log_proxy_error (proxy, "proxy feed error - "); | ||||||
| 			goto oops; | 			goto oops; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @ -1267,7 +1313,9 @@ qse_printf (QSE_T("#####INVALID HEADER FROM PEER [%.*hs]\n"), (int)proxy->buflen | |||||||
| 				} | 				} | ||||||
| 				else | 				else | ||||||
| 				{ | 				{ | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("TRAILING DATA=%d, [%hs]\n"), (int)QSE_MBS_LEN(proxy->res), QSE_MBS_CPTR(proxy->res,proxy->res_consumed)); | qse_printf (QSE_T("TRAILING DATA=%d, [%hs]\n"), (int)QSE_MBS_LEN(proxy->res), QSE_MBS_CPTR(proxy->res,proxy->res_consumed)); | ||||||
|  | #endif | ||||||
| 					/* switch to the next phase */ | 					/* switch to the next phase */ | ||||||
| 					task->main = task_main_proxy_3; | 					task->main = task_main_proxy_3; | ||||||
| 					task->trigger[2].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | 					task->trigger[2].mask |= QSE_HTTPD_TASK_TRIGGER_WRITE; | ||||||
| @ -1301,7 +1349,6 @@ static int task_main_proxy_1 ( | |||||||
| 	int http_errnum = 500; | 	int http_errnum = 500; | ||||||
|  |  | ||||||
| 	/* wait for peer to get connected */ | 	/* wait for peer to get connected */ | ||||||
| qse_printf (QSE_T("task_main_proxy_1....\n")); |  | ||||||
|  |  | ||||||
| 	if (task->trigger[0].mask & QSE_HTTPD_TASK_TRIGGER_READABLE || | 	if (task->trigger[0].mask & QSE_HTTPD_TASK_TRIGGER_READABLE || | ||||||
| 	    task->trigger[0].mask & QSE_HTTPD_TASK_TRIGGER_WRITABLE) | 	    task->trigger[0].mask & QSE_HTTPD_TASK_TRIGGER_WRITABLE) | ||||||
| @ -1312,18 +1359,23 @@ qse_printf (QSE_T("task_main_proxy_1....\n")); | |||||||
| 		n = httpd->opt.scb.peer.connected (httpd, &proxy->peer); | 		n = httpd->opt.scb.peer.connected (httpd, &proxy->peer); | ||||||
| 		if (n <= -1)  | 		if (n <= -1)  | ||||||
| 		{ | 		{ | ||||||
| 			/* improve error conversion */ | 			/* TODO: translate more error codes to http error codes... */ | ||||||
|  |  | ||||||
| 			if (httpd->errnum == QSE_HTTPD_ENOENT) http_errnum = 404; | 			if (httpd->errnum == QSE_HTTPD_ENOENT) http_errnum = 404; | ||||||
| 			else if (httpd->errnum == QSE_HTTPD_EACCES ||  | 			else if (httpd->errnum == QSE_HTTPD_EACCES ||  | ||||||
| 			         httpd->errnum == QSE_HTTPD_ECONN) http_errnum = 403; | 			         httpd->errnum == QSE_HTTPD_ECONN) http_errnum = 403; | ||||||
| qse_printf (QSE_T("task_main_proxy_1.... ERROR \n")); |  | ||||||
|  | 			if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 				log_proxy_error (proxy, "proxy connect error - "); | ||||||
|  |  | ||||||
| 			goto oops; | 			goto oops; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (n >= 1)  | 		if (n >= 1)  | ||||||
| 		{ | 		{ | ||||||
|  | 			/* connected to the peer now */ | ||||||
|  |  | ||||||
| 			proxy->peer_status |= PROXY_PEER_CONNECTED; | 			proxy->peer_status |= PROXY_PEER_CONNECTED; | ||||||
| qse_printf (QSE_T("FINALLY connected to peer ...............................\n")); |  | ||||||
|  |  | ||||||
| 			if (proxy->req) | 			if (proxy->req) | ||||||
| 			{ | 			{ | ||||||
| @ -1360,7 +1412,6 @@ static int task_main_proxy ( | |||||||
| 	proxy_peer_htrd_xtn_t* xtn; | 	proxy_peer_htrd_xtn_t* xtn; | ||||||
| 	int http_errnum = 500; | 	int http_errnum = 500; | ||||||
| 	int n; | 	int n; | ||||||
| qse_printf (QSE_T("task_main_proxy....\n")); |  | ||||||
|  |  | ||||||
| 	if (proxy->init_failed) goto oops; | 	if (proxy->init_failed) goto oops; | ||||||
|  |  | ||||||
| @ -1384,11 +1435,13 @@ qse_printf (QSE_T("task_main_proxy....\n")); | |||||||
| 	n = httpd->opt.scb.peer.open (httpd, &proxy->peer); | 	n = httpd->opt.scb.peer.open (httpd, &proxy->peer); | ||||||
| 	if (n <= -1) | 	if (n <= -1) | ||||||
| 	{ | 	{ | ||||||
| /* TODO: translate error code to http error... */ | 		/* TODO: translate more error codes to http error codes... */ | ||||||
| 		if (httpd->errnum == QSE_HTTPD_ENOENT) http_errnum = 404; | 		if (httpd->errnum == QSE_HTTPD_ENOENT) http_errnum = 404; | ||||||
| 		else if (httpd->errnum == QSE_HTTPD_EACCES || | 		else if (httpd->errnum == QSE_HTTPD_EACCES || | ||||||
| 		         httpd->errnum == QSE_HTTPD_ECONN) http_errnum = 403; | 		         httpd->errnum == QSE_HTTPD_ECONN) http_errnum = 403; | ||||||
| qse_printf (QSE_T("caanot open peer....\n")); |  | ||||||
|  | 		if (httpd->opt.trait & QSE_HTTPD_LOGACT)  | ||||||
|  | 			log_proxy_error (proxy, "proxy connect error - "); | ||||||
| 		goto oops; | 		goto oops; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | |||||||
| @ -63,7 +63,6 @@ static void task_fini_resol ( | |||||||
| 	qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_task_t* task) | 	qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_task_t* task) | ||||||
| { | { | ||||||
| 	task_resol_t* resol = (task_resol_t*)task->ctx; | 	task_resol_t* resol = (task_resol_t*)task->ctx; | ||||||
| qse_printf (QSE_T("task_fini_resol\n")); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static int task_main_resol ( | static int task_main_resol ( | ||||||
|  | |||||||
| @ -183,7 +183,6 @@ qse_httpd_task_t* qse_httpd_entaskformat ( | |||||||
| 	task.main = task_main_format; | 	task.main = task_main_format; | ||||||
| 	task.ctx = &data; | 	task.ctx = &data; | ||||||
|  |  | ||||||
| qse_printf (QSE_T("SEND: [%.*hs]\n"), (int)l, buf); |  | ||||||
| 	return qse_httpd_entask ( | 	return qse_httpd_entask ( | ||||||
| 		httpd, client, pred, &task, QSE_SIZEOF(data)); | 		httpd, client, pred, &task, QSE_SIZEOF(data)); | ||||||
| } | } | ||||||
|  | |||||||
| @ -431,7 +431,9 @@ static void free_client ( | |||||||
|  |  | ||||||
| 	qse_htrd_close (client->htrd); | 	qse_htrd_close (client->htrd); | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("Debug: CLOSING SOCKET %d\n"), client->handle.i); | qse_printf (QSE_T("Debug: CLOSING SOCKET %d\n"), client->handle.i); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (client->status & CLIENT_HANDLE_IN_MUX) | 	if (client->status & CLIENT_HANDLE_IN_MUX) | ||||||
| 	{ | 	{ | ||||||
| @ -518,10 +520,12 @@ static int accept_client ( | |||||||
|  |  | ||||||
| 		if (httpd->opt.scb.server.accept (httpd, server, &clibuf) <= -1)  | 		if (httpd->opt.scb.server.accept (httpd, server, &clibuf) <= -1)  | ||||||
| 		{ | 		{ | ||||||
|  | #if 0 | ||||||
| /* TODO: proper logging */ | /* TODO: proper logging */ | ||||||
| qse_char_t tmp[128]; | qse_char_t tmp[128]; | ||||||
| qse_nwadtostr (&server->dope.nwad, tmp, QSE_COUNTOF(tmp), QSE_NWADTOSTR_ALL); | qse_nwadtostr (&server->dope.nwad, tmp, QSE_COUNTOF(tmp), QSE_NWADTOSTR_ALL); | ||||||
| qse_printf (QSE_T("failed to accept from server [%s] [%d]\n"), tmp, server->handle.i); | qse_printf (QSE_T("failed to accept from server [%s] [%d]\n"), tmp, server->handle.i); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 			return -1; | 			return -1; | ||||||
| 		} | 		} | ||||||
| @ -538,7 +542,9 @@ qse_printf (QSE_T("failed to accept from server [%s] [%d]\n"), tmp, server->hand | |||||||
| 			return -1; | 			return -1; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("MUX ADDHND CLIENT READ %d\n"), client->handle.i); | qse_printf (QSE_T("MUX ADDHND CLIENT READ %d\n"), client->handle.i); | ||||||
|  | #endif | ||||||
| 		if (httpd->opt.scb.mux.addhnd ( | 		if (httpd->opt.scb.mux.addhnd ( | ||||||
| 			httpd, mux, client->handle, QSE_HTTPD_MUX_READ, client) <= -1) | 			httpd, mux, client->handle, QSE_HTTPD_MUX_READ, client) <= -1) | ||||||
| 		{ | 		{ | ||||||
| @ -605,7 +611,9 @@ static int activate_servers (qse_httpd_t* httpd) | |||||||
| /* | /* | ||||||
| 			httpd->opt.rcb.log (httpd, 0, QSE_T("cannot activate %s"), buf); | 			httpd->opt.rcb.log (httpd, 0, QSE_T("cannot activate %s"), buf); | ||||||
| */ | */ | ||||||
|  | #if 0 | ||||||
| qse_printf(QSE_T("cannot activate [%s]\n"), buf); | qse_printf(QSE_T("cannot activate [%s]\n"), buf); | ||||||
|  | #endif | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @ -617,7 +625,9 @@ qse_printf(QSE_T("cannot activate [%s]\n"), buf); | |||||||
| /* | /* | ||||||
| 			httpd->opt.rcb.log (httpd, 0, QSE_T("cannot activate %s - "), buf); | 			httpd->opt.rcb.log (httpd, 0, QSE_T("cannot activate %s - "), buf); | ||||||
| */ | */ | ||||||
|  | #if 0 | ||||||
| qse_printf(QSE_T("cannot add handle [%s]\n"), buf); | qse_printf(QSE_T("cannot add handle [%s]\n"), buf); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 			httpd->opt.scb.server.close (httpd, server); | 			httpd->opt.scb.server.close (httpd, server); | ||||||
| 			continue; | 			continue; | ||||||
| @ -1202,7 +1212,9 @@ qse_httpd_task_t* qse_httpd_entask ( | |||||||
| 		httpd->opt.scb.mux.delhnd (httpd, httpd->mux, client->handle); | 		httpd->opt.scb.mux.delhnd (httpd, httpd->mux, client->handle); | ||||||
| 		client->status &= ~CLIENT_HANDLE_IN_MUX; | 		client->status &= ~CLIENT_HANDLE_IN_MUX; | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
| qse_printf (QSE_T("MUX ADDHND CLIENT RW(ENTASK) %d\n"), client->handle.i); | qse_printf (QSE_T("MUX ADDHND CLIENT RW(ENTASK) %d\n"), client->handle.i); | ||||||
|  | #endif | ||||||
| 		if (httpd->opt.scb.mux.addhnd ( | 		if (httpd->opt.scb.mux.addhnd ( | ||||||
| 			httpd, httpd->mux, client->handle,  | 			httpd, httpd->mux, client->handle,  | ||||||
| 			QSE_HTTPD_MUX_READ | QSE_HTTPD_MUX_WRITE,  | 			QSE_HTTPD_MUX_READ | QSE_HTTPD_MUX_WRITE,  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user