mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
PHP script fix
This commit is contained in:
parent
672dbc2ef4
commit
583d61ee2e
42
configure
vendored
42
configure
vendored
|
@ -23093,8 +23093,12 @@ if test "${enable_CRPWS+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_CRPWS"; then
|
if test -z "$enable_CRPWS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_CRPWS="yes"
|
||||||
|
else
|
||||||
enable_CRPWS="no"
|
enable_CRPWS="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_CRPWS" = "yes"; then
|
if test "$enable_CRPWS" = "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT 1" >>confdefs.h
|
$as_echo "#define U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT 1" >>confdefs.h
|
||||||
|
@ -23111,8 +23115,12 @@ if test "${enable_check_time+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_check_time"; then
|
if test -z "$enable_check_time"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_check_time="yes"
|
||||||
|
else
|
||||||
enable_check_time="no"
|
enable_check_time="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_check_time" = "yes"; then
|
if test "$enable_check_time" = "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_SERVER_CHECK_TIME_BETWEEN_REQUEST 1" >>confdefs.h
|
$as_echo "#define U_SERVER_CHECK_TIME_BETWEEN_REQUEST 1" >>confdefs.h
|
||||||
|
@ -23165,8 +23173,12 @@ if test "${enable_HIS+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_HIS" ; then
|
if test -z "$enable_HIS" ; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HIS="yes"
|
||||||
|
else
|
||||||
enable_HIS="no"
|
enable_HIS="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HIS" = "yes"; then
|
if test "$enable_HIS" = "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_HTTP_INOTIFY_SUPPORT 1" >>confdefs.h
|
$as_echo "#define U_HTTP_INOTIFY_SUPPORT 1" >>confdefs.h
|
||||||
|
@ -23183,8 +23195,12 @@ if test "${enable_log+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_log"; then
|
if test -z "$enable_log"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_log="yes"
|
||||||
|
else
|
||||||
enable_log="no"
|
enable_log="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_log" != "yes"; then
|
if test "$enable_log" != "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_LOG_DISABLE 1" >>confdefs.h
|
$as_echo "#define U_LOG_DISABLE 1" >>confdefs.h
|
||||||
|
@ -23201,7 +23217,11 @@ if test "${enable_GSDS+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_GSDS"; then
|
if test -z "$enable_GSDS"; then
|
||||||
enable_GSDS="$enable_debug"
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_GSDS="yes"
|
||||||
|
else
|
||||||
|
enable_GSDS="no"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if test "$enable_GSDS" = "yes"; then
|
if test "$enable_GSDS" = "yes"; then
|
||||||
|
|
||||||
|
@ -23219,8 +23239,12 @@ if test "${enable_HCRS+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_HCRS"; then
|
if test -z "$enable_HCRS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HCRS="no"
|
||||||
|
else
|
||||||
enable_HCRS="yes"
|
enable_HCRS="yes"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HCRS" != "yes"; then
|
if test "$enable_HCRS" != "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_CACHE_REQUEST_DISABLE 1" >>confdefs.h
|
$as_echo "#define U_CACHE_REQUEST_DISABLE 1" >>confdefs.h
|
||||||
|
@ -23237,8 +23261,12 @@ if test "${enable_HPRS+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_HPRS"; then
|
if test -z "$enable_HPRS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HPRS="no"
|
||||||
|
else
|
||||||
enable_HPRS="yes"
|
enable_HPRS="yes"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HPRS" != "yes"; then
|
if test "$enable_HPRS" != "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_PIPELINE_HOMOGENEOUS_DISABLE 1" >>confdefs.h
|
$as_echo "#define U_PIPELINE_HOMOGENEOUS_DISABLE 1" >>confdefs.h
|
||||||
|
@ -23291,8 +23319,12 @@ if test "${enable_alias+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_alias"; then
|
if test -z "$enable_alias"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_alias="yes"
|
||||||
|
else
|
||||||
enable_alias="no"
|
enable_alias="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_alias" = "yes"; then
|
if test "$enable_alias" = "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_ALIAS 1" >>confdefs.h
|
$as_echo "#define U_ALIAS 1" >>confdefs.h
|
||||||
|
@ -23363,8 +23395,12 @@ if test "${enable_HSTS+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$enable_HSTS"; then
|
if test -z "$enable_HSTS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HSTS="yes"
|
||||||
|
else
|
||||||
enable_HSTS="no"
|
enable_HSTS="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HSTS" = "yes"; then
|
if test "$enable_HSTS" = "yes"; then
|
||||||
|
|
||||||
$as_echo "#define U_HTTP_STRICT_TRANSPORT_SECURITY 1" >>confdefs.h
|
$as_echo "#define U_HTTP_STRICT_TRANSPORT_SECURITY 1" >>confdefs.h
|
||||||
|
@ -25798,7 +25834,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if test -z "$PHPCONFIGINCLUDES"; then
|
if test -z "$PHPCONFIGINCLUDES"; then
|
||||||
PHPCONFIGINCLUDES="-I${php_prefix}/include/php/sapi/embed `$PHPCONFIG --includes`"
|
PHPCONFIGINCLUDES="-I${php_prefix}/include/php5/sapi/embed `$PHPCONFIG --includes`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -25862,7 +25898,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if test -z "$PHPCONFIGLIBS"; then
|
if test -z "$PHPCONFIGLIBS"; then
|
||||||
PHPCONFIGLIBS="-L`$PHPCONFIG --ldflags`/lib -lphp5 `$PHPCONFIG --libs`"
|
PHPCONFIGLIBS="-lphp5 `$PHPCONFIG --libs`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ if test "$use_php" = "yes" ; then
|
||||||
[PHPCONFIGINCLUDES=""])
|
[PHPCONFIGINCLUDES=""])
|
||||||
|
|
||||||
if test -z "$PHPCONFIGINCLUDES"; then
|
if test -z "$PHPCONFIGINCLUDES"; then
|
||||||
PHPCONFIGINCLUDES="-I${php_prefix}/include/php/sapi/embed `$PHPCONFIG --includes`"
|
PHPCONFIGINCLUDES="-I${php_prefix}/include/php5/sapi/embed `$PHPCONFIG --includes`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(PHPCONFIGINCLUDES)
|
AC_SUBST(PHPCONFIGINCLUDES)
|
||||||
|
@ -1312,7 +1312,7 @@ if test "$use_php" = "yes" ; then
|
||||||
[PHPCONFIGLIBS=""])
|
[PHPCONFIGLIBS=""])
|
||||||
|
|
||||||
if test -z "$PHPCONFIGLIBS"; then
|
if test -z "$PHPCONFIGLIBS"; then
|
||||||
PHPCONFIGLIBS="-L`$PHPCONFIG --ldflags`/lib -lphp5 `$PHPCONFIG --libs`"
|
PHPCONFIGLIBS="-lphp5 `$PHPCONFIG --libs`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(PHPCONFIGLIBS)
|
AC_SUBST(PHPCONFIGLIBS)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
class UFile;
|
class UFile;
|
||||||
|
class UHTTP;
|
||||||
class UDialog;
|
class UDialog;
|
||||||
class UFileConfig;
|
class UFileConfig;
|
||||||
class UServer_Base;
|
class UServer_Base;
|
||||||
|
@ -147,6 +148,17 @@ public:
|
||||||
argv_exec[ncmd] = (char*) argument;
|
argv_exec[ncmd] = (char*) argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* getArgument(int n) const __pure
|
||||||
|
{
|
||||||
|
U_TRACE(0, "UCommand::getArgument(%d)", n)
|
||||||
|
|
||||||
|
char* result = (argv_exec ? argv_exec[n] : 0);
|
||||||
|
|
||||||
|
U_INTERNAL_ASSERT(result == 0 || u_isText((const unsigned char*)result, u__strlen(result, __PRETTY_FUNCTION__)))
|
||||||
|
|
||||||
|
U_RETURN(result);
|
||||||
|
}
|
||||||
|
|
||||||
void setNumArgument(int32_t n = 1, bool bfree = false);
|
void setNumArgument(int32_t n = 1, bool bfree = false);
|
||||||
|
|
||||||
// MANAGE FILE ARGUMENT
|
// MANAGE FILE ARGUMENT
|
||||||
|
@ -210,16 +222,7 @@ public:
|
||||||
U_RETURN(result);
|
U_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* getCommand() const __pure
|
char* getCommand() const __pure { return getArgument(isShellScript() ? 2 : 0); }
|
||||||
{
|
|
||||||
U_TRACE(0, "UCommand::getCommand()")
|
|
||||||
|
|
||||||
char* result = (argv_exec ? argv_exec[(isShellScript() ? 2 : 0)] : 0);
|
|
||||||
|
|
||||||
U_INTERNAL_ASSERT(result == 0 || u_isText((const unsigned char*)result, u__strlen(result, __PRETTY_FUNCTION__)))
|
|
||||||
|
|
||||||
U_RETURN(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// SERVICES
|
// SERVICES
|
||||||
|
|
||||||
|
@ -322,6 +325,7 @@ private:
|
||||||
UCommand& operator=(const UCommand&) { return *this; }
|
UCommand& operator=(const UCommand&) { return *this; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
friend class UHTTP;
|
||||||
friend class UDialog;
|
friend class UDialog;
|
||||||
friend class UServer_Base;
|
friend class UServer_Base;
|
||||||
friend class UProxyPlugIn;
|
friend class UProxyPlugIn;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <ulib/utility/lock.h>
|
#include <ulib/utility/lock.h>
|
||||||
|
|
||||||
class UHTTP;
|
class UHTTP;
|
||||||
|
class UHTTP2;
|
||||||
class Application;
|
class Application;
|
||||||
class UTimeThread;
|
class UTimeThread;
|
||||||
class UProxyPlugIn;
|
class UProxyPlugIn;
|
||||||
|
@ -166,6 +167,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
friend class UHTTP;
|
friend class UHTTP;
|
||||||
|
friend class UHTTP2;
|
||||||
friend class Application;
|
friend class Application;
|
||||||
friend class UTimeThread;
|
friend class UTimeThread;
|
||||||
friend class UProxyPlugIn;
|
friend class UProxyPlugIn;
|
||||||
|
|
|
@ -48,8 +48,9 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static bool fcgi_keep_conn;
|
||||||
|
static char environment_type;
|
||||||
static UClient_Base* connection;
|
static UClient_Base* connection;
|
||||||
static bool fcgi_keep_conn, bphp;
|
|
||||||
|
|
||||||
void set_FCGIBeginRequest();
|
void set_FCGIBeginRequest();
|
||||||
static void fill_FCGIBeginRequest(u_char type, u_short content_length);
|
static void fill_FCGIBeginRequest(u_char type, u_short content_length);
|
||||||
|
|
|
@ -242,12 +242,13 @@ protected:
|
||||||
static void sendError();
|
static void sendError();
|
||||||
static void manageData();
|
static void manageData();
|
||||||
static void manageHeaders();
|
static void manageHeaders();
|
||||||
|
static void handlerResponse();
|
||||||
static bool readBodyRequest();
|
static bool readBodyRequest();
|
||||||
static bool updateSetting(const char* ptr, uint32_t len);
|
static bool updateSetting(const char* ptr, uint32_t len);
|
||||||
static void decodeHeaders(const char* ptr, const char* endptr);
|
static void decodeHeaders(const char* ptr, const char* endptr);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static const char* getFrameTypeDescription();
|
static const char* getFrameTypeDescription(char type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool setIndexStaticTable(UHashMap<void*>* ptable, const char* key, uint32_t length)
|
static bool setIndexStaticTable(UHashMap<void*>* ptable, const char* key, uint32_t length)
|
||||||
|
|
|
@ -531,11 +531,12 @@ public:
|
||||||
// CGI
|
// CGI
|
||||||
|
|
||||||
typedef struct ucgi {
|
typedef struct ucgi {
|
||||||
char sh_script;
|
|
||||||
char dir[503];
|
|
||||||
const char* interpreter;
|
const char* interpreter;
|
||||||
|
char environment_type;
|
||||||
|
char dir[503];
|
||||||
} ucgi;
|
} ucgi;
|
||||||
|
|
||||||
|
static UCommand* pcmd;
|
||||||
static UString* geoip;
|
static UString* geoip;
|
||||||
static UString* fcgi_uri_mask;
|
static UString* fcgi_uri_mask;
|
||||||
static UString* scgi_uri_mask;
|
static UString* scgi_uri_mask;
|
||||||
|
@ -546,7 +547,7 @@ public:
|
||||||
static bool runCGI(bool set_environment);
|
static bool runCGI(bool set_environment);
|
||||||
static bool getCGIEnvironment(UString& environment, int mask);
|
static bool getCGIEnvironment(UString& environment, int mask);
|
||||||
static bool processCGIOutput(bool cgi_sh_script, bool bheaders);
|
static bool processCGIOutput(bool cgi_sh_script, bool bheaders);
|
||||||
static bool processCGIRequest(UCommand& cmd, const char* cgi_dir);
|
static bool processCGIRequest(UCommand* cmd, UHTTP::ucgi* cgi = 0);
|
||||||
|
|
||||||
// USP (ULib Servlet Page)
|
// USP (ULib Servlet Page)
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(CRPWS,
|
AC_ARG_ENABLE(CRPWS,
|
||||||
[ --enable-CRPWS enable Client Response Partial Write Support [[default=no]]])
|
[ --enable-CRPWS enable Client Response Partial Write Support [[default=no]]])
|
||||||
if test -z "$enable_CRPWS"; then
|
if test -z "$enable_CRPWS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_CRPWS="yes"
|
||||||
|
else
|
||||||
enable_CRPWS="no"
|
enable_CRPWS="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_CRPWS" = "yes"; then
|
if test "$enable_CRPWS" = "yes"; then
|
||||||
AC_DEFINE(U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT, 1, [enable client response partial write support])
|
AC_DEFINE(U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT, 1, [enable client response partial write support])
|
||||||
fi
|
fi
|
||||||
|
@ -102,8 +106,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(check-time,
|
AC_ARG_ENABLE(check-time,
|
||||||
[ --enable-check-time enable server check time between request for parallelization [[default=no]]])
|
[ --enable-check-time enable server check time between request for parallelization [[default=no]]])
|
||||||
if test -z "$enable_check_time"; then
|
if test -z "$enable_check_time"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_check_time="yes"
|
||||||
|
else
|
||||||
enable_check_time="no"
|
enable_check_time="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_check_time" = "yes"; then
|
if test "$enable_check_time" = "yes"; then
|
||||||
AC_DEFINE(U_SERVER_CHECK_TIME_BETWEEN_REQUEST, 1, [enable server check time between request for parallelization])
|
AC_DEFINE(U_SERVER_CHECK_TIME_BETWEEN_REQUEST, 1, [enable server check time between request for parallelization])
|
||||||
fi
|
fi
|
||||||
|
@ -135,8 +143,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(HIS,
|
AC_ARG_ENABLE(HIS,
|
||||||
[ --enable-HIS enable HTTP Inotify Support [[default=no]]])
|
[ --enable-HIS enable HTTP Inotify Support [[default=no]]])
|
||||||
if test -z "$enable_HIS" ; then
|
if test -z "$enable_HIS" ; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HIS="yes"
|
||||||
|
else
|
||||||
enable_HIS="no"
|
enable_HIS="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HIS" = "yes"; then
|
if test "$enable_HIS" = "yes"; then
|
||||||
AC_DEFINE(U_HTTP_INOTIFY_SUPPORT, 1, [enable HTTP inotify support])
|
AC_DEFINE(U_HTTP_INOTIFY_SUPPORT, 1, [enable HTTP inotify support])
|
||||||
fi
|
fi
|
||||||
|
@ -146,8 +158,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(log,
|
AC_ARG_ENABLE(log,
|
||||||
[ --enable-log enable client and server log support [[default=no]]])
|
[ --enable-log enable client and server log support [[default=no]]])
|
||||||
if test -z "$enable_log"; then
|
if test -z "$enable_log"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_log="yes"
|
||||||
|
else
|
||||||
enable_log="no"
|
enable_log="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_log" != "yes"; then
|
if test "$enable_log" != "yes"; then
|
||||||
AC_DEFINE(U_LOG_DISABLE, 1, [disable client and server log support])
|
AC_DEFINE(U_LOG_DISABLE, 1, [disable client and server log support])
|
||||||
fi
|
fi
|
||||||
|
@ -157,7 +173,11 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(GSDS,
|
AC_ARG_ENABLE(GSDS,
|
||||||
[ --enable-GSDS enable GDB Stack Dump Support [[default=no]]])
|
[ --enable-GSDS enable GDB Stack Dump Support [[default=no]]])
|
||||||
if test -z "$enable_GSDS"; then
|
if test -z "$enable_GSDS"; then
|
||||||
enable_GSDS="$enable_debug"
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_GSDS="yes"
|
||||||
|
else
|
||||||
|
enable_GSDS="no"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if test "$enable_GSDS" = "yes"; then
|
if test "$enable_GSDS" = "yes"; then
|
||||||
AC_DEFINE(U_GDB_STACK_DUMP_ENABLE, 1, [enable GDB stack dump support])
|
AC_DEFINE(U_GDB_STACK_DUMP_ENABLE, 1, [enable GDB stack dump support])
|
||||||
|
@ -168,8 +188,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(HCRS,
|
AC_ARG_ENABLE(HCRS,
|
||||||
[ --enable-HCRS enable Cache Request Support [[default=no]]])
|
[ --enable-HCRS enable Cache Request Support [[default=no]]])
|
||||||
if test -z "$enable_HCRS"; then
|
if test -z "$enable_HCRS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HCRS="no"
|
||||||
|
else
|
||||||
enable_HCRS="yes"
|
enable_HCRS="yes"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HCRS" != "yes"; then
|
if test "$enable_HCRS" != "yes"; then
|
||||||
AC_DEFINE(U_CACHE_REQUEST_DISABLE, 1, [disable cache request support])
|
AC_DEFINE(U_CACHE_REQUEST_DISABLE, 1, [disable cache request support])
|
||||||
fi
|
fi
|
||||||
|
@ -179,8 +203,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(HPRS,
|
AC_ARG_ENABLE(HPRS,
|
||||||
[ --enable-HPRS enable Homogeneous Pipeline Request Support [[default=yes]]])
|
[ --enable-HPRS enable Homogeneous Pipeline Request Support [[default=yes]]])
|
||||||
if test -z "$enable_HPRS"; then
|
if test -z "$enable_HPRS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HPRS="no"
|
||||||
|
else
|
||||||
enable_HPRS="yes"
|
enable_HPRS="yes"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HPRS" != "yes"; then
|
if test "$enable_HPRS" != "yes"; then
|
||||||
AC_DEFINE(U_PIPELINE_HOMOGENEOUS_DISABLE, 1, [disable homogeneous pipeline request support])
|
AC_DEFINE(U_PIPELINE_HOMOGENEOUS_DISABLE, 1, [disable homogeneous pipeline request support])
|
||||||
fi
|
fi
|
||||||
|
@ -212,8 +240,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(alias,
|
AC_ARG_ENABLE(alias,
|
||||||
[ --enable-alias enable alias URI support [[default=no]]])
|
[ --enable-alias enable alias URI support [[default=no]]])
|
||||||
if test -z "$enable_alias"; then
|
if test -z "$enable_alias"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_alias="yes"
|
||||||
|
else
|
||||||
enable_alias="no"
|
enable_alias="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_alias" = "yes"; then
|
if test "$enable_alias" = "yes"; then
|
||||||
AC_DEFINE(U_ALIAS, 1, [enable alias URI support])
|
AC_DEFINE(U_ALIAS, 1, [enable alias URI support])
|
||||||
fi
|
fi
|
||||||
|
@ -256,8 +288,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
|
||||||
AC_ARG_ENABLE(HSTS,
|
AC_ARG_ENABLE(HSTS,
|
||||||
[ --enable-HSTS enable HTTP Strict Transport Security support [[default=no]]])
|
[ --enable-HSTS enable HTTP Strict Transport Security support [[default=no]]])
|
||||||
if test -z "$enable_HSTS"; then
|
if test -z "$enable_HSTS"; then
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
enable_HSTS="yes"
|
||||||
|
else
|
||||||
enable_HSTS="no"
|
enable_HSTS="no"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if test "$enable_HSTS" = "yes"; then
|
if test "$enable_HSTS" = "yes"; then
|
||||||
AC_DEFINE(U_HTTP_STRICT_TRANSPORT_SECURITY, 1, [enable HTTP Strict Transport Security support])
|
AC_DEFINE(U_HTTP_STRICT_TRANSPORT_SECURITY, 1, [enable HTTP Strict Transport Security support])
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -146,8 +146,8 @@ void UFCGIPlugIn::fill_FCGIBeginRequest(u_char type, u_short content_length)
|
||||||
|
|
||||||
U_CREAT_FUNC(server_plugin_fcgi, UFCGIPlugIn)
|
U_CREAT_FUNC(server_plugin_fcgi, UFCGIPlugIn)
|
||||||
|
|
||||||
bool UFCGIPlugIn::bphp;
|
|
||||||
bool UFCGIPlugIn::fcgi_keep_conn;
|
bool UFCGIPlugIn::fcgi_keep_conn;
|
||||||
|
char UFCGIPlugIn::environment_type;
|
||||||
UClient_Base* UFCGIPlugIn::connection;
|
UClient_Base* UFCGIPlugIn::connection;
|
||||||
|
|
||||||
UFCGIPlugIn::UFCGIPlugIn()
|
UFCGIPlugIn::UFCGIPlugIn()
|
||||||
|
@ -235,7 +235,7 @@ int UFCGIPlugIn::handlerInit()
|
||||||
UHTTP::valias->push_back(*UHTTP::fcgi_uri_mask);
|
UHTTP::valias->push_back(*UHTTP::fcgi_uri_mask);
|
||||||
UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/nostat"));
|
UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/nostat"));
|
||||||
|
|
||||||
bphp = UHTTP::fcgi_uri_mask->equal(U_CONSTANT_TO_PARAM("*.php"));
|
environment_type = (UHTTP::fcgi_uri_mask->equal(U_CONSTANT_TO_PARAM("*.php")) ? U_PHP : U_CGI);
|
||||||
|
|
||||||
U_RETURN(U_PLUGIN_HANDLER_PROCESSED | U_PLUGIN_HANDLER_GO_ON);
|
U_RETURN(U_PLUGIN_HANDLER_PROCESSED | U_PLUGIN_HANDLER_GO_ON);
|
||||||
# endif
|
# endif
|
||||||
|
@ -274,7 +274,7 @@ int UFCGIPlugIn::handlerRequest()
|
||||||
|
|
||||||
UString environment(U_CAPACITY);
|
UString environment(U_CAPACITY);
|
||||||
|
|
||||||
if (UHTTP::getCGIEnvironment(environment, bphp ? U_PHP : U_CGI) == false) U_RETURN(U_PLUGIN_HANDLER_ERROR);
|
if (UHTTP::getCGIEnvironment(environment, environment_type) == false) U_RETURN(U_PLUGIN_HANDLER_ERROR);
|
||||||
|
|
||||||
n = u_split(U_STRING_TO_PARAM(environment), envp, 0);
|
n = u_split(U_STRING_TO_PARAM(environment), envp, 0);
|
||||||
|
|
||||||
|
|
|
@ -450,7 +450,7 @@ int UHttpPlugIn::handlerRun() // NB: we use this method because now we have the
|
||||||
UServer_Base::update_date =
|
UServer_Base::update_date =
|
||||||
UServer_Base::update_date3 = true;
|
UServer_Base::update_date3 = true;
|
||||||
|
|
||||||
UClientImage_Base::iov_vec[1].iov_base = (caddr_t)ULog::date.date3; // Date: Wed, 20 Jun 2012 11:43:17 GMT\r\nServer: ULib\r\n...
|
UClientImage_Base::iov_vec[1].iov_base = (caddr_t)ULog::date.date3; // Date: Wed, 20 Jun 2012 11:43:17 GMT\r\nServer: ULib\r\nConnection: close\r\n
|
||||||
UClientImage_Base::iov_vec[1].iov_len = 6+29+2+12+2+17+2;
|
UClientImage_Base::iov_vec[1].iov_len = 6+29+2+12+2+17+2;
|
||||||
|
|
||||||
# if defined(ENABLE_THREAD) && !defined(U_LOG_ENABLE) && !defined(USE_LIBZ)
|
# if defined(ENABLE_THREAD) && !defined(U_LOG_ENABLE) && !defined(USE_LIBZ)
|
||||||
|
|
|
@ -92,7 +92,7 @@ int UProxyPlugIn::handlerRequest()
|
||||||
{
|
{
|
||||||
if (UHTTP::service->environment) UClientImage_Base::environment->append(UHTTP::service->environment);
|
if (UHTTP::service->environment) UClientImage_Base::environment->append(UHTTP::service->environment);
|
||||||
|
|
||||||
if (UHTTP::processCGIRequest(*(UHTTP::service->command), "") &&
|
if (UHTTP::processCGIRequest(UHTTP::service->command) &&
|
||||||
UHTTP::processCGIOutput(false, false))
|
UHTTP::processCGIOutput(false, false))
|
||||||
{
|
{
|
||||||
if (UHTTP::service->isResponseForClient()) output_to_client = true; // send output as response to client...
|
if (UHTTP::service->isResponseForClient()) output_to_client = true; // send output as response to client...
|
||||||
|
|
|
@ -45,7 +45,6 @@ static void register_server_variables(zval* track_vars_array TSRMLS_DC)
|
||||||
if (UHTTP::getCGIEnvironment(*UClientImage_Base::environment, U_PHP))
|
if (UHTTP::getCGIEnvironment(*UClientImage_Base::environment, U_PHP))
|
||||||
{
|
{
|
||||||
char** envp;
|
char** envp;
|
||||||
|
|
||||||
int32_t nenv = UCommand::setEnvironment(*UClientImage_Base::environment, envp);
|
int32_t nenv = UCommand::setEnvironment(*UClientImage_Base::environment, envp);
|
||||||
|
|
||||||
php_import_environment_variables(track_vars_array TSRMLS_CC);
|
php_import_environment_variables(track_vars_array TSRMLS_CC);
|
||||||
|
@ -91,6 +90,10 @@ static int send_headers(sapi_headers_struct* sapi_headers)
|
||||||
|
|
||||||
U_http_info.nResponseCode = SG(sapi_headers).http_response_code;
|
U_http_info.nResponseCode = SG(sapi_headers).http_response_code;
|
||||||
|
|
||||||
|
if (U_IS_HTTP_VALID_RESPONSE(U_http_info.nResponseCode) == false) U_http_info.nResponseCode = HTTP_OK;
|
||||||
|
|
||||||
|
U_DUMP("HTTP status = (%d %S)", U_http_info.nResponseCode, UHTTP::getStatusDescription())
|
||||||
|
|
||||||
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,30 +127,22 @@ extern U_EXPORT bool runPHP(const char* script);
|
||||||
{
|
{
|
||||||
U_TRACE(0, "::runPHP(%S)", script)
|
U_TRACE(0, "::runPHP(%S)", script)
|
||||||
|
|
||||||
/*
|
/**
|
||||||
char str[512];
|
* char str[512];
|
||||||
zval ret_value;
|
* zval ret_value;
|
||||||
int exit_status;
|
* int exit_status;
|
||||||
|
* zend_first_try
|
||||||
zend_first_try
|
* {
|
||||||
{
|
* PG(during_request_startup) = 0;
|
||||||
PG(during_request_startup) = 0;
|
* snprintf(str, sizeof(str), "include (\"%s\");", script);
|
||||||
|
* zend_eval_string(str, &ret_value, str TSRMLS_CC);
|
||||||
// run the specified PHP script file
|
* exit_status = Z_LVAL(ret_value);
|
||||||
|
* } zend_catch
|
||||||
snprintf(str, sizeof(str), "include (\"%s\");", script);
|
* {
|
||||||
|
* exit_status = EG(exit_status);
|
||||||
zend_eval_string(str, &ret_value, str TSRMLS_CC);
|
* }
|
||||||
|
* zend_end_try();
|
||||||
exit_status = Z_LVAL(ret_value);
|
* return exit_status;
|
||||||
} zend_catch
|
|
||||||
{
|
|
||||||
exit_status = EG(exit_status);
|
|
||||||
}
|
|
||||||
|
|
||||||
zend_end_try();
|
|
||||||
|
|
||||||
return exit_status;
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool esito = true;
|
bool esito = true;
|
||||||
|
@ -270,40 +265,32 @@ extern U_EXPORT void UPHP_end();
|
||||||
php_embed_module.ini_entries = 0;
|
php_embed_module.ini_entries = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/**
|
||||||
extern U_EXPORT void UPHP_set_var(const char* varname, const char* varval);
|
* extern U_EXPORT void UPHP_set_var(const char* varname, const char* varval);
|
||||||
U_EXPORT void UPHP_set_var(const char* varname, const char* varval)
|
* U_EXPORT void UPHP_set_var(const char* varname, const char* varval)
|
||||||
{
|
* {
|
||||||
zval* var;
|
* zval* var;
|
||||||
MAKE_STD_ZVAL(var);
|
* MAKE_STD_ZVAL(var);
|
||||||
ZVAL_STRING(var, varval, 1);
|
* ZVAL_STRING(var, varval, 1);
|
||||||
|
* zend_hash_update(&EG(symbol_table), varname, strlen(varname) + 1, &var, sizeof(zval*), 0);
|
||||||
zend_hash_update(&EG(symbol_table), varname, strlen(varname) + 1, &var, sizeof(zval*), 0);
|
* }
|
||||||
}
|
* extern U_EXPORT const char* UPHP_get_var(const char* varname);
|
||||||
|
* U_EXPORT const char* UPHP_get_var(const char* varname)
|
||||||
extern U_EXPORT const char* UPHP_get_var(const char* varname);
|
* {
|
||||||
U_EXPORT const char* UPHP_get_var(const char* varname)
|
* zval** data = 0;
|
||||||
{
|
* const char* ret = NULL;
|
||||||
zval** data = 0;
|
* if (zend_hash_find(&EG(symbol_table), varname, strlen(varname) + 1, (void**)&data) == FAILURE)
|
||||||
const char* ret = NULL;
|
* {
|
||||||
|
* printf("Name not found in $GLOBALS\n");
|
||||||
if (zend_hash_find(&EG(symbol_table), varname, strlen(varname) + 1, (void**)&data) == FAILURE)
|
* return "";
|
||||||
{
|
* }
|
||||||
printf("Name not found in $GLOBALS\n");
|
* if (data == 0)
|
||||||
|
* {
|
||||||
return "";
|
* printf("Value is NULL (not possible for symbol_table?)\n");
|
||||||
}
|
* return "";
|
||||||
|
* }
|
||||||
if (data == 0)
|
* ret = Z_STRVAL_PP(data);
|
||||||
{
|
* return ret;
|
||||||
printf("Value is NULL (not possible for symbol_table?)\n");
|
* }
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = Z_STRVAL_PP(data);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,44 +432,6 @@ void UHTTP2::dtor()
|
||||||
U_TRACE(0, "UHTTP2::dtor()")
|
U_TRACE(0, "UHTTP2::dtor()")
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHTTP2::sendError()
|
|
||||||
{
|
|
||||||
U_TRACE(0, "UHTTP2::sendError()")
|
|
||||||
|
|
||||||
U_INTERNAL_ASSERT_DIFFERS(nerror, NO_ERROR)
|
|
||||||
|
|
||||||
char buffer[HTTP2_FRAME_HEADER_SIZE+8] = { 0, 0, 4, // frame size
|
|
||||||
RST_STREAM, // header frame
|
|
||||||
0, // end header flags
|
|
||||||
0, 0, 0, 0, // stream id
|
|
||||||
0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0 };
|
|
||||||
char* ptr = buffer;
|
|
||||||
|
|
||||||
if (frame.stream_id)
|
|
||||||
{
|
|
||||||
*(uint32_t*)(ptr+5) = htonl(frame.stream_id);
|
|
||||||
*(uint32_t*)(ptr+9) = htonl(nerror);
|
|
||||||
|
|
||||||
if (USocketExt::write(UServer_Base::csocket, buffer, HTTP2_FRAME_HEADER_SIZE+4, UServer_Base::timeoutMS) != HTTP2_FRAME_HEADER_SIZE+4) U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ptr[2] = 8;
|
|
||||||
ptr[3] = GOAWAY;
|
|
||||||
|
|
||||||
U_INTERNAL_ASSERT_POINTER(pConnection)
|
|
||||||
|
|
||||||
pConnection->state = CONN_STATE_IS_CLOSING;
|
|
||||||
|
|
||||||
*(uint32_t*)(ptr+ 5) = 0;
|
|
||||||
*(uint32_t*)(ptr+ 9) = htonl(pConnection->max_processed_stream_id);
|
|
||||||
*(uint32_t*)(ptr+13) = htonl(nerror);
|
|
||||||
|
|
||||||
if (USocketExt::write(UServer_Base::csocket, buffer, HTTP2_FRAME_HEADER_SIZE+8, UServer_Base::timeoutMS) != HTTP2_FRAME_HEADER_SIZE+8) U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UHTTP2::updateSetting(const char* ptr, uint32_t len)
|
bool UHTTP2::updateSetting(const char* ptr, uint32_t len)
|
||||||
{
|
{
|
||||||
U_TRACE(0, "UHTTP2::updateSetting(%#.*S,%u)", len, ptr, len)
|
U_TRACE(0, "UHTTP2::updateSetting(%#.*S,%u)", len, ptr, len)
|
||||||
|
@ -893,7 +855,13 @@ case_4_5: // / - /index.html
|
||||||
|
|
||||||
// determine the value (if necessary)
|
// determine the value (if necessary)
|
||||||
|
|
||||||
if (value_is_indexed) value = *(index == 4 ? str_path_root : str_path_index);
|
if (value_is_indexed)
|
||||||
|
{
|
||||||
|
value = *(index == 4 ? str_path_root : str_path_index);
|
||||||
|
|
||||||
|
U_http_info.uri = value.data();
|
||||||
|
U_http_info.uri_len = value.size();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptr += hpackDecodeString((const unsigned char*)ptr, (const unsigned char*)endptr, &value);
|
ptr += hpackDecodeString((const unsigned char*)ptr, (const unsigned char*)endptr, &value);
|
||||||
|
@ -912,9 +880,9 @@ case_4_5: // / - /index.html
|
||||||
|
|
||||||
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
U_INTERNAL_DUMP("URI = %.*S", U_HTTP_URI_TO_TRACE)
|
U_INTERNAL_DUMP("URI = %.*S", U_HTTP_URI_TO_TRACE)
|
||||||
}
|
|
||||||
|
|
||||||
goto insert;
|
goto insert;
|
||||||
|
|
||||||
|
@ -1191,8 +1159,8 @@ insert:
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[HTTP2_FRAME_HEADER_SIZE+5] = { 0, 0, 5, // frame size
|
char buffer[HTTP2_FRAME_HEADER_SIZE+5] = { 0, 0, 5, // frame size
|
||||||
1, // header frame
|
HEADERS, // header frame
|
||||||
4, // end header flags
|
FLAG_END_HEADERS, // end header flags
|
||||||
0, 0, 0, 0, // stream id
|
0, 0, 0, 0, // stream id
|
||||||
8, 3, '1', '0', '0' }; // use literal header field without indexing - indexed name
|
8, 3, '1', '0', '0' }; // use literal header field without indexing - indexed name
|
||||||
|
|
||||||
|
@ -1267,7 +1235,7 @@ loop:
|
||||||
frame.stream_id = ntohl(*(uint32_t*)(ptr+5) & 0x7fffffff);
|
frame.stream_id = ntohl(*(uint32_t*)(ptr+5) & 0x7fffffff);
|
||||||
|
|
||||||
U_DUMP("frame { length = %d stream_id = %d type = (%d, %s) flags = %d } = %#.*S", frame.length,
|
U_DUMP("frame { length = %d stream_id = %d type = (%d, %s) flags = %d } = %#.*S", frame.length,
|
||||||
frame.stream_id, frame.type, getFrameTypeDescription(), frame.flags, frame.length, ptr + HTTP2_FRAME_HEADER_SIZE)
|
frame.stream_id, frame.type, getFrameTypeDescription(frame.type), frame.flags, frame.length, ptr + HTTP2_FRAME_HEADER_SIZE)
|
||||||
|
|
||||||
U_INTERNAL_ASSERT_MINOR(frame.length, (int32_t)settings.max_frame_size)
|
U_INTERNAL_ASSERT_MINOR(frame.length, (int32_t)settings.max_frame_size)
|
||||||
|
|
||||||
|
@ -1319,6 +1287,8 @@ loop:
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
settings_ack = true;
|
settings_ack = true;
|
||||||
|
|
||||||
|
if (UClientImage_Base::rbuffer->size() == UClientImage_Base::rstart) goto end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1639,19 +1609,135 @@ loop:
|
||||||
U_RETURN(false);
|
U_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UHTTP2::sendError()
|
||||||
|
{
|
||||||
|
U_TRACE(0, "UHTTP2::sendError()")
|
||||||
|
|
||||||
|
U_INTERNAL_ASSERT_DIFFERS(nerror, NO_ERROR)
|
||||||
|
|
||||||
|
char buffer[HTTP2_FRAME_HEADER_SIZE+8] = { 0, 0, 4, // frame size
|
||||||
|
RST_STREAM, // header frame
|
||||||
|
FLAG_NONE, // flags
|
||||||
|
0, 0, 0, 0, // stream id
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0 };
|
||||||
|
char* ptr = buffer;
|
||||||
|
|
||||||
|
if (frame.stream_id)
|
||||||
|
{
|
||||||
|
*(uint32_t*)(ptr+5) = htonl(frame.stream_id);
|
||||||
|
*(uint32_t*)(ptr+9) = htonl(nerror);
|
||||||
|
|
||||||
|
if (USocketExt::write(UServer_Base::csocket, buffer, HTTP2_FRAME_HEADER_SIZE+4, UServer_Base::timeoutMS) != HTTP2_FRAME_HEADER_SIZE+4) U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ptr[2] = 8;
|
||||||
|
ptr[3] = GOAWAY;
|
||||||
|
|
||||||
|
U_INTERNAL_ASSERT_POINTER(pConnection)
|
||||||
|
|
||||||
|
pConnection->state = CONN_STATE_IS_CLOSING;
|
||||||
|
|
||||||
|
// *(uint32_t*)(ptr+ 5) = 0;
|
||||||
|
*(uint32_t*)(ptr+ 9) = htonl(pConnection->max_processed_stream_id);
|
||||||
|
*(uint32_t*)(ptr+13) = htonl(nerror);
|
||||||
|
|
||||||
|
if (USocketExt::write(UServer_Base::csocket, buffer, HTTP2_FRAME_HEADER_SIZE+8, UServer_Base::timeoutMS) != HTTP2_FRAME_HEADER_SIZE+8) U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UHTTP2::handlerResponse()
|
||||||
|
{
|
||||||
|
U_TRACE(0, "UHTTP2::handlerResponse()")
|
||||||
|
|
||||||
|
unsigned char buffer[8192] = { 0, 0, 0, // frame size
|
||||||
|
HEADERS, // header frame
|
||||||
|
FLAG_END_HEADERS, // end header flags
|
||||||
|
0, 0, 0, 0, // stream id
|
||||||
|
8, 3, '0', '0', '0' }; // use literal header field without indexing - indexed name
|
||||||
|
|
||||||
|
// \000\000#
|
||||||
|
// \001
|
||||||
|
// \004
|
||||||
|
// \000\000\000\001
|
||||||
|
// \b\003403
|
||||||
|
// v\004\000UHTa
|
||||||
|
|
||||||
|
char* ptr = (char*)buffer;
|
||||||
|
int32_t sz = HTTP2_FRAME_HEADER_SIZE+1;
|
||||||
|
|
||||||
|
switch (U_http_info.nResponseCode)
|
||||||
|
{
|
||||||
|
case HTTP_OK: ptr[HTTP2_FRAME_HEADER_SIZE] = 0x80 | 8; break;
|
||||||
|
case HTTP_NO_CONTENT: ptr[HTTP2_FRAME_HEADER_SIZE] = 0x80 | 9; break;
|
||||||
|
case HTTP_PARTIAL: ptr[HTTP2_FRAME_HEADER_SIZE] = 0x80 | 10; break;
|
||||||
|
case HTTP_NOT_MODIFIED: ptr[HTTP2_FRAME_HEADER_SIZE] = 0x80 | 11; break;
|
||||||
|
case HTTP_BAD_REQUEST: ptr[HTTP2_FRAME_HEADER_SIZE] = 0x80 | 12; break;
|
||||||
|
case HTTP_NOT_FOUND: ptr[HTTP2_FRAME_HEADER_SIZE] = 0x80 | 13; break;
|
||||||
|
case HTTP_INTERNAL_ERROR: ptr[HTTP2_FRAME_HEADER_SIZE] = 0x80 | 14; break;
|
||||||
|
|
||||||
|
default: // use literal header field without indexing - indexed name
|
||||||
|
{
|
||||||
|
sz += 4;
|
||||||
|
|
||||||
|
ptr[HTTP2_FRAME_HEADER_SIZE+2] = (U_http_info.nResponseCode / 100) + '0';
|
||||||
|
U_NUM2STR16(ptr+HTTP2_FRAME_HEADER_SIZE+3, U_http_info.nResponseCode % 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// literal header field with indexing (indexed name)
|
||||||
|
|
||||||
|
unsigned char* dst = buffer+sz;
|
||||||
|
|
||||||
|
// server: ULib
|
||||||
|
// date: Wed, 20 Jun 2012 11:43:17 GMT
|
||||||
|
|
||||||
|
*dst = 0x40;
|
||||||
|
dst = hpackEncodeInt(dst, 54, (1<<6)-1);
|
||||||
|
dst += hpackEncodeString(dst, U_CONSTANT_TO_PARAM("ULib"));
|
||||||
|
*dst = 0x40;
|
||||||
|
dst = hpackEncodeInt(dst, 33, (1<<6)-1);
|
||||||
|
|
||||||
|
// u__memcpy(dst, "v\004\000UHTa", U_CONSTANT_SIZE("v\004\000UHTa"), __PRETTY_FUNCTION__);
|
||||||
|
// dst += U_CONSTANT_SIZE("v\004\000UHTa");
|
||||||
|
|
||||||
|
#if defined(ENABLE_THREAD) && !defined(U_LOG_ENABLE) && !defined(USE_LIBZ)
|
||||||
|
U_INTERNAL_ASSERT_POINTER(u_pthread_time)
|
||||||
|
U_INTERNAL_ASSERT_EQUALS(UClientImage_Base::iov_vec[1].iov_base, ULog::ptr_shared_date->date3)
|
||||||
|
#else
|
||||||
|
U_INTERNAL_ASSERT_EQUALS(UClientImage_Base::iov_vec[1].iov_base, ULog::date.date3)
|
||||||
|
|
||||||
|
ULog::updateDate3();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dst += hpackEncodeString(dst, ((char*)UClientImage_Base::iov_vec[1].iov_base)+6, 29); // Date: Wed, 20 Jun 2012 11:43:17 GMT\r\nServer: ULib\r\nConnection: close\r\n
|
||||||
|
|
||||||
|
sz = dst - buffer;
|
||||||
|
|
||||||
|
*(uint32_t*) ptr = htonl((sz-HTTP2_FRAME_HEADER_SIZE) << 8);
|
||||||
|
ptr[3] = HEADERS;
|
||||||
|
*(uint32_t*)(ptr+5) = htonl(pStream->id);
|
||||||
|
|
||||||
|
U_DUMP("frame response { length = %d stream_id = %d type = (%d, %s) flags = %d } = %#.*S", ntohl(*(uint32_t*)ptr & 0x00ffffff) >> 8,
|
||||||
|
ntohl(*(uint32_t*)(ptr+5) & 0x7fffffff), ptr[3], getFrameTypeDescription(ptr[3]), ptr[4], ntohl(*(uint32_t*)ptr & 0x00ffffff) >> 8, ptr + HTTP2_FRAME_HEADER_SIZE)
|
||||||
|
|
||||||
|
if (USocketExt::write(UServer_Base::csocket, ptr, sz, UServer_Base::timeoutMS) != sz) nerror = FLOW_CONTROL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENTRY
|
#ifdef ENTRY
|
||||||
#undef ENTRY
|
#undef ENTRY
|
||||||
#endif
|
#endif
|
||||||
#define ENTRY(n) n: descr = #n; break
|
#define ENTRY(n) n: descr = #n; break
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const char* UHTTP2::getFrameTypeDescription()
|
const char* UHTTP2::getFrameTypeDescription(char type)
|
||||||
{
|
{
|
||||||
U_TRACE(0, "UHTTP2::getFrameTypeDescription()")
|
U_TRACE(0, "UHTTP2::getFrameTypeDescription(%d)", type)
|
||||||
|
|
||||||
const char* descr;
|
const char* descr;
|
||||||
|
|
||||||
switch (frame.type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ENTRY(DATA);
|
case ENTRY(DATA);
|
||||||
case ENTRY(HEADERS);
|
case ENTRY(HEADERS);
|
||||||
|
|
|
@ -109,6 +109,7 @@ uint32_t UHTTP::limit_request_body = U_STRING_MAX_SIZE;
|
||||||
uint32_t UHTTP::request_read_timeout;
|
uint32_t UHTTP::request_read_timeout;
|
||||||
const char* UHTTP::usp_page_key;
|
const char* UHTTP::usp_page_key;
|
||||||
|
|
||||||
|
UCommand* UHTTP::pcmd;
|
||||||
UDataSession* UHTTP::data_session;
|
UDataSession* UHTTP::data_session;
|
||||||
UDataSession* UHTTP::data_storage;
|
UDataSession* UHTTP::data_storage;
|
||||||
UMimeMultipart* UHTTP::formMulti;
|
UMimeMultipart* UHTTP::formMulti;
|
||||||
|
@ -764,6 +765,7 @@ void UHTTP::ctor()
|
||||||
U_INTERNAL_ASSERT_EQUALS(ext, 0)
|
U_INTERNAL_ASSERT_EQUALS(ext, 0)
|
||||||
U_INTERNAL_ASSERT_EQUALS(etag, 0)
|
U_INTERNAL_ASSERT_EQUALS(etag, 0)
|
||||||
U_INTERNAL_ASSERT_EQUALS(file, 0)
|
U_INTERNAL_ASSERT_EQUALS(file, 0)
|
||||||
|
U_INTERNAL_ASSERT_EQUALS(pcmd, 0)
|
||||||
U_INTERNAL_ASSERT_EQUALS(geoip, 0)
|
U_INTERNAL_ASSERT_EQUALS(geoip, 0)
|
||||||
U_INTERNAL_ASSERT_EQUALS(tmpdir, 0)
|
U_INTERNAL_ASSERT_EQUALS(tmpdir, 0)
|
||||||
U_INTERNAL_ASSERT_EQUALS(request, 0)
|
U_INTERNAL_ASSERT_EQUALS(request, 0)
|
||||||
|
@ -780,6 +782,7 @@ void UHTTP::ctor()
|
||||||
UWebSocket::str_allocate();
|
UWebSocket::str_allocate();
|
||||||
|
|
||||||
file = U_NEW(UFile);
|
file = U_NEW(UFile);
|
||||||
|
pcmd = U_NEW(UCommand);
|
||||||
ext = U_NEW(UString);
|
ext = U_NEW(UString);
|
||||||
etag = U_NEW(UString);
|
etag = U_NEW(UString);
|
||||||
geoip = U_NEW(UString(U_CAPACITY));
|
geoip = U_NEW(UString(U_CAPACITY));
|
||||||
|
@ -1382,6 +1385,7 @@ void UHTTP::dtor()
|
||||||
delete ext;
|
delete ext;
|
||||||
delete etag;
|
delete etag;
|
||||||
delete file;
|
delete file;
|
||||||
|
delete pcmd;
|
||||||
delete geoip;
|
delete geoip;
|
||||||
delete suffix;
|
delete suffix;
|
||||||
delete tmpdir;
|
delete tmpdir;
|
||||||
|
@ -1666,14 +1670,10 @@ int UHTTP::handlerDataPending()
|
||||||
|
|
||||||
(void) manageRequest();
|
(void) manageRequest();
|
||||||
|
|
||||||
/*
|
U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
|
||||||
return 1 // child of parallelization
|
|
||||||
return -1 // parent of parallelization
|
|
||||||
*/
|
|
||||||
|
|
||||||
U_RETURN(0);
|
U_RETURN(-1);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return UClientImage_Base::handlerDataPending();
|
return UClientImage_Base::handlerDataPending();
|
||||||
|
@ -2907,8 +2907,7 @@ set_x_http_forward_for: U_http_info.ip_client = ptr+pos1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next:
|
next: U_INTERNAL_DUMP("char (after cr/newline) = %C", pn[2])
|
||||||
U_INTERNAL_DUMP("char (after cr/newline) = %C", pn[2])
|
|
||||||
|
|
||||||
if (U_http_info.endHeader == 0 &&
|
if (U_http_info.endHeader == 0 &&
|
||||||
u_get_unalignedp32(pn) == U_MULTICHAR_CONSTANT32('\r','\n','\r','\n'))
|
u_get_unalignedp32(pn) == U_MULTICHAR_CONSTANT32('\r','\n','\r','\n'))
|
||||||
|
@ -3035,7 +3034,7 @@ bool UHTTP::runCGI(bool set_environment)
|
||||||
|
|
||||||
U_INTERNAL_ASSERT_POINTER(cgi)
|
U_INTERNAL_ASSERT_POINTER(cgi)
|
||||||
|
|
||||||
U_INTERNAL_DUMP("cgi->dir = %S cgi->sh_script = %b cgi->interpreter = %S", cgi->dir, cgi->sh_script, cgi->interpreter)
|
U_INTERNAL_DUMP("cgi->dir = %S cgi->environment_type = %d cgi->interpreter = %S", cgi->dir, cgi->environment_type, cgi->interpreter)
|
||||||
|
|
||||||
// NB: we can't use the relativ path because after we call chdir()...
|
// NB: we can't use the relativ path because after we call chdir()...
|
||||||
|
|
||||||
|
@ -3052,9 +3051,11 @@ bool UHTTP::runCGI(bool set_environment)
|
||||||
|
|
||||||
// ULIB facility: check if present form data and convert them in parameters for shell script...
|
// ULIB facility: check if present form data and convert them in parameters for shell script...
|
||||||
|
|
||||||
if (cgi->sh_script) setCGIShellScript(command);
|
if (cgi->environment_type == U_SHELL) setCGIShellScript(command);
|
||||||
|
|
||||||
UCommand cmd(command);
|
U_INTERNAL_ASSERT_POINTER(pcmd)
|
||||||
|
|
||||||
|
pcmd->setCommand(command);
|
||||||
|
|
||||||
if (set_environment)
|
if (set_environment)
|
||||||
{
|
{
|
||||||
|
@ -3062,14 +3063,14 @@ bool UHTTP::runCGI(bool set_environment)
|
||||||
|
|
||||||
// NB: process the CGI request with fork....
|
// NB: process the CGI request with fork....
|
||||||
|
|
||||||
if (getCGIEnvironment(*UClientImage_Base::environment, cgi->sh_script ? U_SHELL : U_CGI) == false ||
|
if (getCGIEnvironment(*UClientImage_Base::environment, cgi->environment_type) == false ||
|
||||||
UServer_Base::startParallelization()) // parent of parallelization
|
UServer_Base::startParallelization()) // parent of parallelization
|
||||||
{
|
{
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processCGIRequest(cmd, cgi->dir)) // NB: in case of failure we have already the response...
|
if (processCGIRequest(pcmd, cgi)) // NB: in case of failure we have already the response...
|
||||||
{
|
{
|
||||||
next: U_DUMP("UServer_Base::isParallelizationChild() = %b UServer_Base::isParallelizationParent() = %b", UServer_Base::isParallelizationChild(), UServer_Base::isParallelizationParent())
|
next: U_DUMP("UServer_Base::isParallelizationChild() = %b UServer_Base::isParallelizationParent() = %b", UServer_Base::isParallelizationChild(), UServer_Base::isParallelizationParent())
|
||||||
|
|
||||||
|
@ -3078,7 +3079,7 @@ next: U_DUMP("UServer_Base::isParallelizationChild() = %b UServer_Base::isParall
|
||||||
|
|
||||||
if (set_environment == false ||
|
if (set_environment == false ||
|
||||||
(U_ClientImage_parallelization != 2 && // 2 => parent of parallelization
|
(U_ClientImage_parallelization != 2 && // 2 => parent of parallelization
|
||||||
processCGIOutput(cgi->sh_script, false)))
|
processCGIOutput(cgi->environment_type == U_SHELL, false)))
|
||||||
{
|
{
|
||||||
U_RETURN(true);
|
U_RETURN(true);
|
||||||
}
|
}
|
||||||
|
@ -3845,7 +3846,7 @@ file_in_cache:
|
||||||
# if defined(USE_RUBY) || defined(USE_PHP) || defined(HAVE_LIBTCC)
|
# if defined(USE_RUBY) || defined(USE_PHP) || defined(HAVE_LIBTCC)
|
||||||
if (U_http_is_request_nostat == false &&
|
if (U_http_is_request_nostat == false &&
|
||||||
U_HTTP_QUERY_STREQ("_nav_") == false &&
|
U_HTTP_QUERY_STREQ("_nav_") == false &&
|
||||||
runDynamicPage())
|
(checkForPathName(), runDynamicPage()))
|
||||||
{
|
{
|
||||||
U_RETURN(U_PLUGIN_HANDLER_FINISHED);
|
U_RETURN(U_PLUGIN_HANDLER_FINISHED);
|
||||||
}
|
}
|
||||||
|
@ -5536,6 +5537,8 @@ UString UHTTP::getHeaderForResponse()
|
||||||
#ifndef U_HTTP2_DISABLE
|
#ifndef U_HTTP2_DISABLE
|
||||||
if (U_http_version == '2')
|
if (U_http_version == '2')
|
||||||
{
|
{
|
||||||
|
UHTTP2::handlerResponse();
|
||||||
|
|
||||||
return UString::getStringNull();
|
return UString::getStringNull();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -6039,10 +6042,15 @@ end:
|
||||||
# if defined(DEBUG) && defined(USE_LIBMAGIC)
|
# if defined(DEBUG) && defined(USE_LIBMAGIC)
|
||||||
if (clength > 4)
|
if (clength > 4)
|
||||||
{
|
{
|
||||||
UString tmp = UMagic::getType(UClientImage_Base::wbuffer->c_pointer(U_http_info.endHeader), clength);
|
const char* p = UClientImage_Base::wbuffer->c_pointer(U_http_info.endHeader);
|
||||||
|
|
||||||
|
if (u_isText((const unsigned char*)p, clength))
|
||||||
|
{
|
||||||
|
UString tmp = UMagic::getType(p, clength);
|
||||||
|
|
||||||
U_INTERNAL_ASSERT_EQUALS(memcmp(tmp.data(), U_CONSTANT_TO_PARAM("text")), 0)
|
U_INTERNAL_ASSERT_EQUALS(memcmp(tmp.data(), U_CONSTANT_TO_PARAM("text")), 0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
ptr1 = ptr+sz;
|
ptr1 = ptr+sz;
|
||||||
|
@ -7544,18 +7552,14 @@ check: if (usp_src) goto end;
|
||||||
|
|
||||||
ptr = pathname->c_pointer(pathname->size() - 2);
|
ptr = pathname->c_pointer(pathname->size() - 2);
|
||||||
|
|
||||||
cgi->sh_script = (memcmp(ptr, U_CONSTANT_TO_PARAM("sh")) == 0);
|
if (suffix->equal(U_CONSTANT_TO_PARAM("sh"))) { cgi->interpreter = U_PATH_SHELL; cgi->environment_type = U_SHELL; }
|
||||||
|
else if (suffix->equal(U_CONSTANT_TO_PARAM("php"))) { cgi->interpreter = "php-cgi"; cgi->environment_type = U_PHP; }
|
||||||
|
else if (suffix->equal(U_CONSTANT_TO_PARAM("pl"))) { cgi->interpreter = "perl"; cgi->environment_type = U_CGI; }
|
||||||
|
else if (suffix->equal(U_CONSTANT_TO_PARAM("py"))) { cgi->interpreter = "python"; cgi->environment_type = U_CGI; }
|
||||||
|
else if (suffix->equal(U_CONSTANT_TO_PARAM("rb"))) { cgi->interpreter = "ruby"; cgi->environment_type = U_CGI; }
|
||||||
|
else { cgi->interpreter = 0; cgi->environment_type = U_CGI; }
|
||||||
|
|
||||||
U_INTERNAL_DUMP("cgi->sh_script = %b", cgi->sh_script)
|
U_INTERNAL_DUMP("cgi->environment_type = %d cgi->interpreter = %S", cgi->environment_type, cgi->interpreter)
|
||||||
|
|
||||||
if (suffix->equal(U_CONSTANT_TO_PARAM("sh"))) cgi->interpreter = U_PATH_SHELL;
|
|
||||||
else if (suffix->equal(U_CONSTANT_TO_PARAM("php"))) cgi->interpreter = "php-cgi";
|
|
||||||
else if (suffix->equal(U_CONSTANT_TO_PARAM("pl"))) cgi->interpreter = "perl";
|
|
||||||
else if (suffix->equal(U_CONSTANT_TO_PARAM("py"))) cgi->interpreter = "python";
|
|
||||||
else if (suffix->equal(U_CONSTANT_TO_PARAM("rb"))) cgi->interpreter = "ruby";
|
|
||||||
else cgi->interpreter = 0;
|
|
||||||
|
|
||||||
U_INTERNAL_DUMP("cgi->interpreter = %S", cgi->interpreter)
|
|
||||||
|
|
||||||
file_data->ptr = cgi;
|
file_data->ptr = cgi;
|
||||||
file_data->mime_index = U_cgi;
|
file_data->mime_index = U_cgi;
|
||||||
|
@ -8202,6 +8206,20 @@ bool UHTTP::getCGIEnvironment(UString& environment, int mask)
|
||||||
if (brequest == false) buffer.snprintf_add("REQUEST_URI=%.*s\n", sz, ptr);
|
if (brequest == false) buffer.snprintf_add("REQUEST_URI=%.*s\n", sz, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((mask & U_PHP) != 0)
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------------------------------
|
||||||
|
// see: http://woozle.org/~neale/papers/php-cgi.html
|
||||||
|
// ---------------------------------------------------------------------------------------------------
|
||||||
|
// PHP_SELF: The filename of the currently executing script, relative to the document root
|
||||||
|
// ---------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
buffer.snprintf_add("PHP_SELF=%.*s\n"
|
||||||
|
"REDIRECT_STATUS=1\n"
|
||||||
|
"SCRIPT_FILENAME=%w%.*s\n",
|
||||||
|
sz, ptr, sz, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
(void) buffer.append(*UServer_Base::cenvironment); // SERVER_(NAME|PORT)
|
(void) buffer.append(*UServer_Base::cenvironment); // SERVER_(NAME|PORT)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8449,25 +8467,6 @@ bool UHTTP::getCGIEnvironment(UString& environment, int mask)
|
||||||
(void) buffer.append(U_CONSTANT_TO_PARAM("\nPATH=/usr/local/bin:/usr/bin:/bin\n"));
|
(void) buffer.append(U_CONSTANT_TO_PARAM("\nPATH=/usr/local/bin:/usr/bin:/bin\n"));
|
||||||
|
|
||||||
if (*geoip) (void) buffer.append(*geoip);
|
if (*geoip) (void) buffer.append(*geoip);
|
||||||
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mask & U_PHP) != 0)
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------------------------------
|
|
||||||
// see: http://woozle.org/~neale/papers/php-cgi.html
|
|
||||||
// ---------------------------------------------------------------------------------------------------
|
|
||||||
// PHP_SELF: The filename of the currently executing script, relative to the document root
|
|
||||||
// ---------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
sz = UHTTP::file->getPathRelativLen();
|
|
||||||
ptr = UHTTP::file->getPathRelativ();
|
|
||||||
|
|
||||||
buffer.snprintf_add("PHP_SELF=%.*s\n"
|
|
||||||
"REDIRECT_STATUS=1\n"
|
|
||||||
"SCRIPT_FILENAME=%.*s\n",
|
|
||||||
sz, ptr, sz, ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -9106,9 +9105,9 @@ error:
|
||||||
U_RETURN(false);
|
U_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UHTTP::processCGIRequest(UCommand& cmd, const char* cgi_dir)
|
bool UHTTP::processCGIRequest(UCommand* cmd, UHTTP::ucgi* cgi)
|
||||||
{
|
{
|
||||||
U_TRACE(0, "UHTTP::processCGIRequest(%p,%S)", &cmd, cgi_dir)
|
U_TRACE(0, "UHTTP::processCGIRequest(%p,%p)", cmd, cgi)
|
||||||
|
|
||||||
static int fd_stderr;
|
static int fd_stderr;
|
||||||
|
|
||||||
|
@ -9116,33 +9115,36 @@ bool UHTTP::processCGIRequest(UCommand& cmd, const char* cgi_dir)
|
||||||
|
|
||||||
U_INTERNAL_DUMP("U_http_method_type = %B URI = %.*S U_http_info.nResponseCode = %d", U_http_method_type, U_HTTP_URI_TO_TRACE, U_http_info.nResponseCode)
|
U_INTERNAL_DUMP("U_http_method_type = %B URI = %.*S U_http_info.nResponseCode = %d", U_http_method_type, U_HTTP_URI_TO_TRACE, U_http_info.nResponseCode)
|
||||||
|
|
||||||
U_ASSERT(cmd.checkForExecute())
|
U_ASSERT(cmd->checkForExecute())
|
||||||
U_INTERNAL_ASSERT(*UClientImage_Base::environment)
|
U_INTERNAL_ASSERT(*UClientImage_Base::environment)
|
||||||
|
|
||||||
cmd.setEnvironment(UClientImage_Base::environment);
|
cmd->setEnvironment(UClientImage_Base::environment);
|
||||||
|
|
||||||
/* When a url ends by "cgi-bin/" it is assumed to be a cgi script.
|
/**
|
||||||
|
* When a url ends by "cgi-bin/" it is assumed to be a cgi script.
|
||||||
* The server changes directory to the location of the script and
|
* The server changes directory to the location of the script and
|
||||||
* executes it after setting QUERY_STRING and other environment variables.
|
* executes it after setting QUERY_STRING and other environment variables.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (cgi_dir[0]) (void) UFile::chdir(cgi_dir, true);
|
if (cgi) (void) UFile::chdir(cgi->dir, true);
|
||||||
|
|
||||||
// execute script...
|
// execute script...
|
||||||
|
|
||||||
if (cgi_timeout) cmd.setTimeout(cgi_timeout);
|
if (cgi_timeout) cmd->setTimeout(cgi_timeout);
|
||||||
|
|
||||||
if (fd_stderr == 0) fd_stderr = UServices::getDevNull("/tmp/processCGIRequest.err");
|
if (fd_stderr == 0) fd_stderr = UServices::getDevNull("/tmp/processCGIRequest.err");
|
||||||
|
|
||||||
bool result = cmd.execute(UClientImage_Base::body->empty() ? 0 : UClientImage_Base::body, UClientImage_Base::wbuffer, -1, fd_stderr);
|
bool result = cmd->execute(UClientImage_Base::body->empty() ? 0 : UClientImage_Base::body, UClientImage_Base::wbuffer, -1, fd_stderr);
|
||||||
|
|
||||||
if (cgi_dir[0]) (void) UFile::chdir(0, true);
|
if (cgi) (void) UFile::chdir(0, true);
|
||||||
|
|
||||||
#ifdef U_LOG_ENABLE
|
#ifdef U_LOG_ENABLE
|
||||||
UServer_Base::logCommandMsgError(cmd.getCommand(), false);
|
UServer_Base::logCommandMsgError(cmd->getCommand(), false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmd.reset(UClientImage_Base::environment);
|
cmd->reset(UClientImage_Base::environment);
|
||||||
|
|
||||||
|
cmd->environment.clear();
|
||||||
|
|
||||||
if (result == false ||
|
if (result == false ||
|
||||||
UClientImage_Base::wbuffer->empty())
|
UClientImage_Base::wbuffer->empty())
|
||||||
|
@ -9158,6 +9160,7 @@ bool UHTTP::processCGIRequest(UCommand& cmd, const char* cgi_dir)
|
||||||
// NB: exit_value consists of the least significant 8 bits of the status argument that the child specified in a call to exit()...
|
// NB: exit_value consists of the least significant 8 bits of the status argument that the child specified in a call to exit()...
|
||||||
|
|
||||||
if (UCommand::exit_value > 128 &&
|
if (UCommand::exit_value > 128 &&
|
||||||
|
cgi->environment_type == U_SHELL &&
|
||||||
U_IS_HTTP_ERROR(UCommand::exit_value + 256))
|
U_IS_HTTP_ERROR(UCommand::exit_value + 256))
|
||||||
{
|
{
|
||||||
U_http_info.nResponseCode = UCommand::exit_value + 256;
|
U_http_info.nResponseCode = UCommand::exit_value + 256;
|
||||||
|
|
|
@ -5,7 +5,7 @@ MAINTAINERCLEANFILES = Makefile.in
|
||||||
DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include
|
DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include
|
||||||
|
|
||||||
EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest \
|
EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest \
|
||||||
*.properties *.test *.sh error_msg workflow doc_parse robots.txt css js benchmark websocket docroot
|
*.properties *.test *.sh error_msg workflow doc_parse robots.txt css js benchmark websocket docroot php.sh
|
||||||
|
|
||||||
## DEFS = -DU_TEST @DEFS@
|
## DEFS = -DU_TEST @DEFS@
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,7 @@ top_srcdir = @top_srcdir@
|
||||||
MAINTAINERCLEANFILES = Makefile.in
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include
|
DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include
|
||||||
EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest \
|
EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest \
|
||||||
*.properties *.test *.sh error_msg workflow doc_parse robots.txt css js benchmark websocket docroot
|
*.properties *.test *.sh error_msg workflow doc_parse robots.txt css js benchmark websocket docroot php.sh
|
||||||
|
|
||||||
TESTS = client_server.test test_manager.test IR.test web_server.test \
|
TESTS = client_server.test test_manager.test IR.test web_server.test \
|
||||||
web_server_multiclient.test web_socket.test $(am__append_1) \
|
web_server_multiclient.test web_socket.test $(am__append_1) \
|
||||||
|
|
93
tests/examples/php.sh
Executable file
93
tests/examples/php.sh
Executable file
|
@ -0,0 +1,93 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Running PHP scripts in ULib
|
||||||
|
|
||||||
|
ARG=$1
|
||||||
|
if [ -z "$ARG" ]; then
|
||||||
|
ARG=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p log out err www/cgi-bin
|
||||||
|
|
||||||
|
rm -f log/php${ARG}.log \
|
||||||
|
out/*.out err/*.err \
|
||||||
|
/tmp/processCGIRequest.err /tmp/server_plugin_fcgi.err \
|
||||||
|
trace.*.[0-9]* object.*.[0-9]* stack.*.[0-9]* mempool.*.[0-9]* \
|
||||||
|
www/trace.*.[0-9]* www/object.*.[0-9]* www/stack.*.[0-9]* www/mempool.*.[0-9]*
|
||||||
|
|
||||||
|
if [ ! -s "www/info.php" ]; then
|
||||||
|
echo -n "<?php phpinfo(); ?>" > www/info.php
|
||||||
|
fi
|
||||||
|
if [ ! -s "www/cgi-bin/index.php" ]; then
|
||||||
|
echo -n "<?php phpinfo(); ?>" > www/cgi-bin/index.php
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ARG" = "1" ]; then
|
||||||
|
#1) run PHP scripts using ULib CGI support
|
||||||
|
cat <<EOF >userver.cfg
|
||||||
|
userver {
|
||||||
|
PORT 8080
|
||||||
|
LOG_FILE_SZ 1M
|
||||||
|
LOG_MSG_SIZE -1
|
||||||
|
DOCUMENT_ROOT www
|
||||||
|
LOG_FILE ../log/php1.log
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
#2) run PHP requests proxed by FastCGI protocol
|
||||||
|
elif [ "$ARG" = "2a" ]; then
|
||||||
|
#a) TCP socket (IP and port) approach
|
||||||
|
cat <<EOF >userver.cfg
|
||||||
|
userver {
|
||||||
|
PORT 8080
|
||||||
|
LOG_FILE_SZ 1M
|
||||||
|
LOG_MSG_SIZE -1
|
||||||
|
DOCUMENT_ROOT www
|
||||||
|
LOG_FILE ../log/php2a.log
|
||||||
|
PLUGIN "fcgi http"
|
||||||
|
}
|
||||||
|
fcgi {
|
||||||
|
FCGI_URI_MASK *.php
|
||||||
|
SERVER 127.0.0.1
|
||||||
|
PORT 9000
|
||||||
|
LOG_FILE ../log/php2a.log
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
elif [ "$ARG" = "2b" ]; then
|
||||||
|
#b) unix domain socket (UDS) approach
|
||||||
|
cat <<EOF >userver.cfg
|
||||||
|
userver {
|
||||||
|
PORT 8080
|
||||||
|
LOG_FILE_SZ 1M
|
||||||
|
LOG_MSG_SIZE -1
|
||||||
|
DOCUMENT_ROOT www
|
||||||
|
LOG_FILE ../log/php2b.log
|
||||||
|
PLUGIN "fcgi http"
|
||||||
|
}
|
||||||
|
fcgi {
|
||||||
|
FCGI_URI_MASK *.php
|
||||||
|
SOCKET_NAME /tmp/fcgi.socket
|
||||||
|
LOG_FILE ../log/php2b.log
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
elif [ "$ARG" = "3" ]; then
|
||||||
|
#3) run PHP scripts using ULib php embedded support (--with-php-embedded).
|
||||||
|
cat <<EOF >userver.cfg
|
||||||
|
userver {
|
||||||
|
PORT 8080
|
||||||
|
LOG_FILE_SZ 1M
|
||||||
|
LOG_MSG_SIZE -1
|
||||||
|
DOCUMENT_ROOT www
|
||||||
|
LOG_FILE ../log/php3.log
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
#UTRACE="0 50M 0"
|
||||||
|
#UTRACE_SIGNAL="0 50M 0"
|
||||||
|
#UOBJDUMP="0 10M 100"
|
||||||
|
#USIMERR="error.sim"
|
||||||
|
export UTRACE UTRACE_SIGNAL UOBJDUMP USIMERR
|
||||||
|
|
||||||
|
#STRACE="strace -t -f -s 100"
|
||||||
|
PID=`( eval "$STRACE userver_tcp -c userver.cfg >>out/php${ARG}.out 2>>err/php${ARG}.err &"; echo $! )`
|
||||||
|
echo "PID = "$PID
|
|
@ -22,9 +22,10 @@ rm -f db/session.ssl* /tmp/ssl_session.txt /tmp/byterange* /tmp/*.memusage.* \
|
||||||
$DOC_ROOT/trace.*userver_*.[0-9]* $DOC_ROOT/object.*userver_*.[0-9]* $DOC_ROOT/stack.*userver_*.[0-9]* $DOC_ROOT/mempool.*userver_*.[0-9]*
|
$DOC_ROOT/trace.*userver_*.[0-9]* $DOC_ROOT/object.*userver_*.[0-9]* $DOC_ROOT/stack.*userver_*.[0-9]* $DOC_ROOT/mempool.*userver_*.[0-9]*
|
||||||
|
|
||||||
#UTRACE="0 100M 0"
|
#UTRACE="0 100M 0"
|
||||||
#UOBJDUMP="0 50M 5000"
|
#UTRACE_SIGNAL="0 50M 0"
|
||||||
|
#UOBJDUMP="0 10M 100"
|
||||||
#USIMERR="error.sim"
|
#USIMERR="error.sim"
|
||||||
export UTRACE UOBJDUMP USIMERR
|
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL
|
||||||
|
|
||||||
if [ "$TERM" = "msys" ]; then
|
if [ "$TERM" = "msys" ]; then
|
||||||
export TMPDIR="c:/tmp"
|
export TMPDIR="c:/tmp"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user