2011-05-09 18:56 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* examples/httpsrv/uhttpd.prg
  * examples/httpsrv/cookie.prg
  * examples/httpsrv/cgifunc.prg
  * examples/httpsrv/session.prg
    * TRUE -> .T.
    * FALSE -> .F.
    * END -> ENDSWITCH
This commit is contained in:
Viktor Szakats
2011-05-09 16:57:32 +00:00
parent f778c9be7c
commit 074926beaf
5 changed files with 101 additions and 92 deletions

View File

@@ -16,6 +16,15 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-05-09 18:56 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* examples/httpsrv/uhttpd.prg
* examples/httpsrv/cookie.prg
* examples/httpsrv/cgifunc.prg
* examples/httpsrv/session.prg
* TRUE -> .T.
* FALSE -> .F.
* END -> ENDSWITCH
2011-05-09 18:48 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rtl/memofile.c
% eliminated two call to hb_fsSeek() and one hb_fsRead() from

View File

@@ -58,7 +58,7 @@
#define CRLF (Chr(13)+Chr(10))
#xtranslate THROW( <oErr> ) => ( Eval( ErrorBlock(), <oErr> ), Break( <oErr> ) )
#define HB_IHASH() HB_HSETCASEMATCH( {=>}, FALSE )
#define HB_IHASH() HB_HSETCASEMATCH( {=>}, .F. )
MEMVAR _SERVER, _GET, _POST, _COOKIE, _REQUEST, _HTTP_REQUEST
@@ -136,7 +136,7 @@ FUNCTION uhttpd_SplitUrl( cUrl )
LOCAL cUri
// Prevents case matching
hb_HSetCaseMatch( hUrl, FALSE )
hb_HSetCaseMatch( hUrl, .F. )
cTemp := cUrl
cUri := ""
@@ -257,7 +257,7 @@ FUNCTION uhttpd_SplitUrl( cUrl )
hb_hSet( hUrl, "URI" , cURI )
// Prevents externals to add something else to this Hash
hb_HSetAutoAdd( hUrl, FALSE )
hb_HSetAutoAdd( hUrl, .F. )
RETURN hUrl
@@ -270,7 +270,7 @@ RETURN hUrl
Parameters:
cString - Initial string
cDelim - Delimiter - default CRLF
lRemDelim - Remove delimiter from return values - default TRUE
lRemDelim - Remove delimiter from return values - default .T.
Returns:
aLines - Array with lines / fields for each element
@@ -286,7 +286,7 @@ FUNCTION uhttpd_SplitString( cString, cDelim, lRemDelim, nCount )
LOCAL nHowMany := 0
DEFAULT cDelim TO ( CHR(13) + CHR(10) )
DEFAULT lRemDelim TO TRUE
DEFAULT lRemDelim TO .T.
DEFAULT nCount TO -1
//WriteToLogFile( "Splitstring: " + cStr( cString ) )
@@ -320,12 +320,12 @@ RETURN aLines
*/
FUNCTION uhttpd_URLEncode( cString, lComplete )
#ifdef HB_USE_HBTIP
DEFAULT lComplete TO TRUE
DEFAULT lComplete TO .T.
RETURN TIPENCODERURL_ENCODE( cString, lComplete )
#else
LOCAL cRet := "", i, nVal, cChar
DEFAULT lComplete TO TRUE
DEFAULT lComplete TO .T.
FOR i := 1 TO Len( cString )
cChar := SubStr( cString, i, 1)
@@ -340,7 +340,7 @@ FUNCTION uhttpd_URLEncode( cString, lComplete )
cChar == '/' .OR. cChar == ';' .OR. cChar == '_'
cRet += cChar
CASE IIF( !lComplete, cChar == ':' .OR. cChar == '?' .OR. cChar == '=', FALSE )
CASE IIF( !lComplete, cChar == ':' .OR. cChar == '?' .OR. cChar == '=', .F. )
cRet += cChar
OTHERWISE
@@ -465,7 +465,7 @@ RETURN aRetVal[ 4, 2 ]
FUNCTION uhttpd_OutputString( cString, aTranslate, lProtected )
LOCAL cHtml
DEFAULT lProtected TO FALSE
DEFAULT lProtected TO .F.
DEFAULT aTranslate TO { { '"', '&quot;' }, { ' ', '&nbsp;' } }
//TraceLog( "OutputString( cString, aTranslate, lProtected )", cString, aTranslate, lProtected )
@@ -711,7 +711,7 @@ PROCEDURE uhttpd_WriteToLogFile( cString, cLog, lCreate )
//DEFAULT cLog TO AppFullPath() + cSep + "logfile.log"
DEFAULT cLog TO cSep + "tmp" + cSep + "logfile.log"
DEFAULT lCreate TO FALSE
DEFAULT lCreate TO .F.
IF cLog <> NIL
@@ -822,7 +822,7 @@ FUNCTION uhttpd_CStrToVal( cExp, cType )
OTHERWISE
Throw( ErrorNew( "CSTR", 0, 3101, ProcName(), "Argument error", { cExp, cType } ) )
END
ENDSWITCH
RETURN NIL

View File

@@ -71,11 +71,11 @@ CLASS uhttpd_Cookie
DATA cDomain
DATA cPath INIT "/"
DATA cExpire
DATA lSecure INIT FALSE
DATA lSecure INIT .F.
DATA lHttpOnly
DATA nExpireDays INIT 0
DATA nExpireSecs INIT 7200 // 1 hour - TODO set environment constant
DATA lCookiesSent INIT FALSE
DATA lCookiesSent INIT .F.
METHOD SetCookie()
METHOD DeleteCookie()
@@ -102,7 +102,7 @@ METHOD SetCookie( cCookieName, xValue, cDomain, cPath, cExpires, lSecure, lHttpO
DEFAULT cDomain TO ::cDomain
DEFAULT cPath TO ::cPath
DEFAULT cExpires TO uhttpd_DateToGMT( Date(), Time(), ::nExpireDays, ::nExpireSecs )
DEFAULT lHttpOnly TO FALSE
DEFAULT lHttpOnly TO .F.
::lHttpOnly := lHttpOnly
@@ -141,7 +141,7 @@ METHOD SetCookie( cCookieName, xValue, cDomain, cPath, cExpires, lSecure, lHttpO
ENDIF
// Send the header
//uhttpd_SetHeader( "Set-Cookie", cStr, FALSE )
//uhttpd_SetHeader( "Set-Cookie", cStr, .F. )
uhttpd_SetHeader( "Set-Cookie", cStr )
RETURN NIL
@@ -166,7 +166,7 @@ METHOD DeleteAllCookies( cDomain, cPath, lSecure ) CLASS uhttpd_Cookie
METHOD GetCookie( cCookieName ) CLASS uhttpd_Cookie
LOCAL cHeader, cRet
LOCAL nPos := 1
DO WHILE TRUE
DO WHILE .T.
IF ( cHeader := uhttpd_GetHeader( "Set-Cookie", @nPos ) ) != NIL
IF cHeader == cCookieName
cRet := cHeader

View File

@@ -115,22 +115,22 @@ CLASS uhttpd_Session
DATA cSID
DATA cSavePath INIT "/tmp"
DATA cName // INIT "SESSIONID"
DATA lAuto_Start INIT FALSE // FALSE = no autostart
DATA lAuto_Start INIT .F. // .F. = no autostart
DATA nGc_Probability INIT 33 // Every 1/3 of checks i'll lunch Session GC
DATA nGc_MaxLifeTime INIT 1440 // seconds - Number of seconds after gc can delete a session
// DATA cSerialize_Handler INIT "HBHTMLLIB"
DATA nCookie_LifeTime INIT 3600 //0 // Number of seconds to keep cookie, 0 = until browser is closed
DATA cCookie_Path INIT "/"
DATA cCookie_Domain
DATA lCookie_Secure INIT FALSE
DATA lUse_Cookies INIT TRUE // TRUE = Use cookies to store session id on client side
DATA lUse_Only_Cookies INIT FALSE
DATA lCookie_Secure INIT .F.
DATA lUse_Cookies INIT .T. // .T. = Use cookies to store session id on client side
DATA lUse_Only_Cookies INIT .F.
DATA cReferrer_Check // If is set check if referrer is equal to, if it isn't block
// DATA cEntropy_File
// DATA nEntropy_Lenght
DATA cCache_Limiter INIT "nocache" // Possible values are: none, nocache, private, private_no_expire, public
DATA nCache_Expire INIT 180 // in minutes, not checked if cCache_Limiter == none or nocache
DATA lUse_Trans_SID INIT FALSE // FALSE = no SID appended to URL
DATA lUse_Trans_SID INIT .F. // .F. = no SID appended to URL
// Session Storage code blocks
DATA bOpen //INIT {|cPath, cName| ::SessionOpen( cPath, cName ) }
@@ -144,7 +144,7 @@ CLASS uhttpd_Session
DATA nActiveSessions INIT 0
DATA lSessionActive INIT FALSE
DATA lSessionActive INIT .F.
METHOD GenerateSID()
METHOD CheckSID()
@@ -198,8 +198,8 @@ METHOD New( cSessionName, cSessionPath ) CLASS uhttpd_Session
RETURN Self
METHOD Start( cSID ) CLASS uhttpd_Session
LOCAL lSendCookie := TRUE
LOCAL lDefine_SID := TRUE
LOCAL lSendCookie := .T.
LOCAL lDefine_SID := .T.
LOCAL xVal, nRand, nPos
LOCAL hUrl
@@ -212,7 +212,7 @@ METHOD Start( cSID ) CLASS uhttpd_Session
//TraceLog( "Active Sessions : " + hb_cStr( ::nActiveSessions ) )
IF ::nActiveSessions <> 0
RETURN FALSE
RETURN .F.
ENDIF
// Start checking ID from global vars
@@ -222,8 +222,8 @@ METHOD Start( cSID ) CLASS uhttpd_Session
IF HB_ISARRAY( ::cSID )
::cSID := ::cSID[ 1 ] // Get Only 1-st
ENDIF
lSendCookie := FALSE
lDefine_SID := FALSE
lSendCookie := .F.
lDefine_SID := .F.
//::oCGI:ToLogFile( "::cSID = " + hb_cStr( ::cSID ), "/pointtoit/tmp/log.txt" )
ENDIF
@@ -231,8 +231,8 @@ METHOD Start( cSID ) CLASS uhttpd_Session
// Check if the SID is NOT valid, someone altered it
//::oCGI:ToLogFile( "::cSID = " + hb_cStr( ::cSID ) + " SID is NOT valid, someone altered it", "/pointtoit/tmp/log.txt" )
::cSID := NIL // invalidate current SID, i'll generate a new one
lSendCookie := TRUE
lDefine_SID := TRUE
lSendCookie := .T.
lDefine_SID := .T.
ENDIF
IF !Empty( ::cSID ) .AND. !Empty( ::cReferrer_Check )
@@ -246,8 +246,8 @@ METHOD Start( cSID ) CLASS uhttpd_Session
//IF !( oUrl:cServer == _SERVER[ "SERVER_NAME" ] )
IF !( hUrl[ "HOST" ] == _SERVER[ "SERVER_NAME" ] )
::cSID := NIL // invalidate current SID, i'll generate a new one
lSendCookie := TRUE
lDefine_SID := TRUE
lSendCookie := .T.
lDefine_SID := .T.
ENDIF
// // Check whether the current request was referred to by
@@ -268,8 +268,8 @@ METHOD Start( cSID ) CLASS uhttpd_Session
// Is use_cookies set to false?
IF !::lUse_Cookies .AND. lSendCookie
lDefine_SID := TRUE
lSendCookie := FALSE
lDefine_SID := .T.
lSendCookie := .F.
ENDIF
// Should we send a cookie?
@@ -314,20 +314,20 @@ METHOD Start( cSID ) CLASS uhttpd_Session
ENDIF
ENDIF
RETURN TRUE
RETURN .T.
METHOD Destroy() CLASS uhttpd_Session
IF ::nActiveSessions == 0
RETURN FALSE
RETURN .F.
ENDIF
// Destroy session
IF !Eval( ::bDestroy, ::cSID )
RETURN FALSE
RETURN .F.
ENDIF
RETURN TRUE
RETURN .T.
METHOD Close() CLASS uhttpd_Session
LOCAL cVal
@@ -335,7 +335,7 @@ METHOD Close() CLASS uhttpd_Session
//TraceLog( "Session Close() - oCGI:h_Session", DumpValue( oCGI:h_Session ) )
IF ::nActiveSessions == 0
RETURN FALSE
RETURN .F.
ENDIF
// Encode session
@@ -351,7 +351,7 @@ METHOD Close() CLASS uhttpd_Session
ENDIF
::nActiveSessions--
RETURN TRUE
RETURN .T.
METHOD Open( cPath, cName ) CLASS uhttpd_Session
RETURN Eval( ::bOpen, cPath, cName )
@@ -367,7 +367,7 @@ RETURN Eval( ::bGC, nMaxLifeTime )
METHOD IsRegistered() CLASS uhttpd_Session
LOCAL lRegistered := FALSE
LOCAL lRegistered := .F.
RETURN lRegistered
METHOD CacheLimiter( cNewLimiter ) CLASS uhttpd_Session
@@ -579,12 +579,12 @@ METHOD SessionOpen( cPath, cName ) CLASS uhttpd_Session
IF cPath <> NIL THEN ::cSavePath := cPath
IF cName <> NIL THEN ::cName := cName
RETURN TRUE
RETURN .T.
METHOD SessionClose() CLASS uhttpd_Session
//TraceLog( "SessionClose()" )
// Nothing to do
RETURN TRUE
RETURN .T.
METHOD SessionRead( cID ) CLASS uhttpd_Session
LOCAL nH
@@ -629,7 +629,7 @@ METHOD SessionWrite( cID, cData ) CLASS uhttpd_Session
LOCAL nH
LOCAL cFile
LOCAL nFileSize
LOCAL lOk := FALSE
LOCAL lOk := .F.
LOCAL nRetry := 0
//TraceLog( "SessionWrite() - cID, cData", cID, cData )
@@ -646,7 +646,7 @@ METHOD SessionWrite( cID, cData ) CLASS uhttpd_Session
IF ( FWrite( nH, @cData, nFileSize ) ) <> nFileSize
uhttpd_Die( "ERROR: On writing session file : " + cFile + ", File error : " + hb_cStr( FError() ) )
ELSE
lOk := TRUE
lOk := .T.
ENDIF
FClose( nH )
ELSE
@@ -662,7 +662,7 @@ METHOD SessionWrite( cID, cData ) CLASS uhttpd_Session
// FErase( cFile )
//ENDIF
// Return that all is ok
lOk := TRUE
lOk := .T.
ENDIF
RETURN lOk
@@ -680,7 +680,7 @@ METHOD SessionDestroy( cID ) CLASS uhttpd_Session
//TraceLog( "SessionDestroy() - cID, oCGI:h_Session", cID, DumpValue( oCGI:h_Session ) )
cFile := ::cSavePath + hb_ps() + ::cName + "_" + cID
lOk := FALSE
lOk := .F.
DO WHILE nRetry++ <= ::nFileRetry
IF ( lOk := ( FErase( cFile ) == 0 ) )
EXIT
@@ -720,7 +720,7 @@ METHOD SessionGC( nMaxLifeTime ) CLASS uhttpd_Session
ENDIF
NEXT
RETURN TRUE
RETURN .T.
STATIC FUNCTION TimeDiffAsSeconds( dDateStart, dDateEnd, cTimeStart, cTimeEnd )
LOCAL aRetVal
@@ -794,7 +794,7 @@ METHOD Encode() CLASS uhttpd_Session
RETURN IIF( !Empty( aSerial ), HB_Serialize( aSerial ), NIL )
METHOD Decode( cData ) CLASS uhttpd_Session
LOCAL lOk := TRUE
LOCAL lOk := .T.
LOCAL cSerial := cData
LOCAL xVal, aElem
//LOCAL cKey
@@ -829,9 +829,9 @@ METHOD Decode( cData ) CLASS uhttpd_Session
OTHERWISE
uhttpd_Die( "ERROR: On deserializing session data" )
lOk := FALSE
lOk := .F.
EXIT
END
ENDSWITCH
ENDDO
RETURN lOk
@@ -844,7 +844,7 @@ METHOD SendCacheLimiter() CLASS uhttpd_Session
uhttpd_SetHeader( 'Expires', uhttpd_DateToGMT( ,,-1, ) )
uhttpd_SetHeader( 'Cache-Control', 'no-cache' )
//uhttpd_SetHeader("Cache-Control", "no-store, no-cache, must-revalidate") // HTTP/1.1
//uhttpd_SetHeader("Cache-Control", "post-check=0, pre-check=0", FALSE )
//uhttpd_SetHeader("Cache-Control", "post-check=0, pre-check=0", .F. )
uhttpd_SetHeader( 'Pragma', 'no-cache' )
CASE ::cCache_Limiter == 'private'
uhttpd_SetHeader( 'Expires', 'Thu, 19 Nov 1981 08:52:00 GMT' )

View File

@@ -140,7 +140,7 @@ REQUEST __HB_EXTERN__
#define HRB_ACTIVATE_CACHE .F. // if .T. caching of HRB modules will be enabled. (NOTE: changes of files will not be loaded until server is active)
#define CR_LF (CHR(13)+CHR(10))
#define HB_IHASH() HB_HSETCASEMATCH( {=>}, FALSE )
#define HB_IHASH() HB_HSETCASEMATCH( {=>}, .F. )
#ifdef __PLATFORM__WINDOWS
REQUEST HB_GT_WVT_DEFAULT
@@ -156,7 +156,7 @@ REQUEST __HB_EXTERN__
// dynamic call for HRB support
DYNAMIC HRBMAIN
STATIC s_lQuitRequest := FALSE
STATIC s_lQuitRequest := .F.
STATIC s_hmtxQueue, s_hmtxServiceThreads, s_hmtxRunningThreads, s_hmtxLog, s_hmtxConsole, s_hmtxBusy
STATIC s_hmtxHRB
@@ -187,7 +187,7 @@ STATIC s_hHandlers := { ;
"/serverstatus" => "server-status" ;
}
//STATIC s_lAcceptPathInfo := TRUE
//STATIC s_lAcceptPathInfo := .T.
// SCRIPTALIASES: now read from ini file
//STATIC s_hScriptAliases := { "/info" => "/cgi-bin/info.hrb" }
@@ -234,22 +234,22 @@ FUNCTION MAIN( ... )
// ----------------------- Parameters defaults -----------------------------
// defaults not changeble via ini file
lStop := FALSE
lStop := .F.
cConfig := EXE_Path() + hb_ps() + APP_NAME + ".ini"
lConsole := TRUE
lConsole := .T.
nStartServiceThreads := START_SERVICE_THREADS
// Check GT version - if I have started app with //GT:NUL then I have to disable
// console and application will start in hidden way.
cGT := HB_GTVERSION()
IF ( cGT == "NUL" )
lConsole := FALSE
lConsole := .F.
ELSE
hb_gtInfo( HB_GTI_NOTIFIERBLOCK, {|nEvent, ...| GT_notifier( nEvent, ... ) } )
ENDIF
// TOCHECK: now not force case insensitive
//HB_HSETCASEMATCH( s_hScriptAliases, FALSE )
//HB_HSETCASEMATCH( s_hScriptAliases, .F. )
// ----------------- Line command parameters checking ----------------------
@@ -269,10 +269,10 @@ FUNCTION MAIN( ... )
cCmdDocumentRoot := hb_PValue( i++ )
CASE cPar == "--indexes" .OR. cPar == "-i"
lCmdIndexes := TRUE
lCmdIndexes := .T.
CASE cPar == "--stop" .OR. cPar == "-s"
lStop := TRUE
lStop := .T.
CASE cPar == "--config" .OR. cPar == "-c"
cConfig := hb_PValue( i++ )
@@ -334,7 +334,7 @@ FUNCTION MAIN( ... )
nMaxThreads := hDefault[ "THREADS" ][ "MAX_NUM" ]
// ATTENTION: script aliases can be in mixed case
// i.e. we can have /info or /Info that will be different unless lScriptAliasMixedCase will be FALSE
// i.e. we can have /info or /Info that will be different unless lScriptAliasMixedCase will be .F.
FOR EACH xVal IN hDefault[ "SCRIPTALIASES" ]
IF HB_ISSTRING( xVal )
hb_HSet( s_hScriptAliases, IIF( lScriptAliasMixedCase, xVal:__enumKey(), Upper( xVal:__enumKey() ) ), xVal )
@@ -615,7 +615,7 @@ FUNCTION MAIN( ... )
ENDIF
// Memory release
//hb_GCAll( TRUE )
//hb_GCAll( .T. )
ENDDO
@@ -653,7 +653,7 @@ STATIC FUNCTION AcceptConnections()
LOCAL lCanNotify
#endif
LOCAL pThread
LOCAL lQuitRequest := FALSE
LOCAL lQuitRequest := .F.
ErrorBlock( { | oError | uhttpd_DefError( oError ) } )
@@ -683,14 +683,14 @@ STATIC FUNCTION AcceptConnections()
#ifdef __PLATFORM__WINDOWS
// releasing resources
IF WIN_SYSREFRESH( 1 ) != 0
lQuitRequest := TRUE
lQuitRequest := .T.
ENDIF
#endif
IF hb_mutexLock( s_hmtxBusy )
IF s_lQuitRequest
hb_mutexUnlock( s_hmtxBusy )
lQuitRequest := TRUE
lQuitRequest := .T.
ENDIF
hb_mutexUnlock( s_hmtxBusy )
ENDIF
@@ -739,7 +739,7 @@ STATIC FUNCTION AcceptConnections()
hb_mutexUnlock( s_hmtxBusy )
ENDIF
lCanNotify := FALSE
lCanNotify := .F.
// If I have no more running threads to use ...
IF nConnections > nMaxThreads
@@ -756,7 +756,7 @@ STATIC FUNCTION AcceptConnections()
IF hb_mutexLock( s_hmtxBusy )
pThread := hb_threadStart( @ServiceConnection() )
AADD( s_aServiceThreads, pThread )
lCanNotify := TRUE
lCanNotify := .T.
hb_mutexUnlock( s_hmtxBusy )
ENDIF
ENDIF
@@ -774,11 +774,11 @@ STATIC FUNCTION AcceptConnections()
IF hb_mutexLock( s_hmtxBusy )
pThread := hb_threadStart( @ProcessConnection() )
AADD( s_aRunningThreads, pThread )
lCanNotify := TRUE
lCanNotify := .T.
hb_mutexUnlock( s_hmtxBusy )
ENDIF
ELSE
lCanNotify := TRUE
lCanNotify := .T.
ENDIF
// Otherwise I send connection to running thread queue
//hb_ToOutDebug( "Len( s_aRunningThreads ) = %i\n\r", Len( s_aRunningThreads ) )
@@ -801,7 +801,7 @@ STATIC FUNCTION AcceptConnections()
STATIC FUNCTION ProcessConnection()
LOCAL hSocket, nLen, cRequest, cSend
LOCAL nMsecs, nParseTime, nPos, nThreadID
LOCAL lQuitRequest := FALSE
LOCAL lQuitRequest := .F.
PRIVATE _SERVER, _GET, _POST, _COOKIE, _SESSION, _REQUEST, _HTTP_REQUEST, _HTTP_RESPONSE, m_cPost
@@ -829,7 +829,7 @@ STATIC FUNCTION ProcessConnection()
#ifdef __PLATFORM__WINDOWS
// releasing resources
IF WIN_SYSREFRESH( 1 ) != 0
lQuitRequest := TRUE
lQuitRequest := .T.
EXIT
ENDIF
#endif
@@ -837,7 +837,7 @@ STATIC FUNCTION ProcessConnection()
IF hb_mutexLock( s_hmtxBusy )
IF s_lQuitRequest
hb_mutexUnlock( s_hmtxBusy )
lQuitRequest := TRUE
lQuitRequest := .T.
EXIT
ENDIF
hb_mutexUnlock( s_hmtxBusy )
@@ -848,7 +848,7 @@ STATIC FUNCTION ProcessConnection()
// received a -1 value, I have to quit
IF HB_ISNUMERIC( hSocket )
lQuitRequest := TRUE
lQuitRequest := .T.
EXIT
ELSEIF hSocket == NIL // no socket received, thread can graceful quit, but ...
@@ -942,7 +942,7 @@ STATIC FUNCTION ProcessConnection()
ENDIF
// Memory release
hb_GCAll( TRUE )
hb_GCAll( .T. )
ENDDO
@@ -954,7 +954,7 @@ STATIC FUNCTION ProcessConnection()
IF !lQuitRequest .AND. hb_mutexLock( s_hmtxBusy )
//hb_ToOutDebug( "Len( s_aRunningThreads ) = %i\n\r", Len( s_aRunningThreads ) )
IF ( nPos := aScan( s_aRunningThreads, hb_threadSelf() ) > 0 )
hb_aDel( s_aRunningThreads, nPos, TRUE )
hb_aDel( s_aRunningThreads, nPos, .T. )
s_nThreads := Len( s_aRunningThreads )
ENDIF
hb_mutexUnlock( s_hmtxBusy )
@@ -966,7 +966,7 @@ STATIC FUNCTION ServiceConnection()
LOCAL hSocket, nLen, cRequest, cSend
LOCAL nMsecs, nParseTime, nPos, nThreadId
LOCAL nError := 500013
LOCAL lQuitRequest := FALSE
LOCAL lQuitRequest := .F.
PRIVATE _SERVER, _GET, _POST, _COOKIE, _SESSION, _REQUEST, _HTTP_REQUEST, _HTTP_RESPONSE, m_cPost
@@ -989,7 +989,7 @@ STATIC FUNCTION ServiceConnection()
#ifdef __PLATFORM__WINDOWS
// releasing resources
IF WIN_SYSREFRESH( 1 ) != 0
lQuitRequest := TRUE
lQuitRequest := .T.
EXIT
ENDIF
#endif
@@ -997,7 +997,7 @@ STATIC FUNCTION ServiceConnection()
IF hb_mutexLock( s_hmtxBusy )
IF s_lQuitRequest
hb_mutexUnlock( s_hmtxBusy )
lQuitRequest := TRUE
lQuitRequest := .T.
EXIT
ENDIF
hb_mutexUnlock( s_hmtxBusy )
@@ -1008,7 +1008,7 @@ STATIC FUNCTION ServiceConnection()
// received a -1 value, I have to quit
IF HB_ISNUMERIC( hSocket )
lQuitRequest := TRUE
lQuitRequest := .T.
EXIT
ELSEIF hSocket == NIL // no socket received, thread can graceful quit, but ...
IF hb_mutexLock( s_hmtxBusy )
@@ -1086,7 +1086,7 @@ STATIC FUNCTION ServiceConnection()
ENDIF
// Memory release
hb_GCAll( TRUE )
hb_GCAll( .T. )
ENDDO
@@ -1097,7 +1097,7 @@ STATIC FUNCTION ServiceConnection()
// here to avoid race condition
IF !lQuitRequest .AND. hb_mutexLock( s_hmtxBusy )
IF ( nPos := aScan( s_aServiceThreads, hb_threadSelf() ) > 0 )
hb_aDel( s_aServiceThreads, nPos, TRUE )
hb_aDel( s_aServiceThreads, nPos, .T. )
s_nServiceThreads := Len( s_aServiceThreads )
ENDIF
hb_mutexUnlock( s_hmtxBusy )
@@ -1631,7 +1631,7 @@ PROCEDURE uhttpd_SetStatusCode(nStatusCode)
PROCEDURE uhttpd_SetHeader( cType, cValue )
//LOCAL nI
//DEFAULT lReplace TO TRUE // Needed from SetCookie()
//DEFAULT lReplace TO .T. // Needed from SetCookie()
hb_HSet( _HTTP_RESPONSE, cType, cValue )
@@ -1668,7 +1668,7 @@ PROCEDURE uhttpd_DelHeader( cType )
LOCAL nI
IF ( nI := ASCAN( t_aHeader, {|x| UPPER( x[ 1 ] ) == UPPER( cType ) } ) ) > 0
hb_aDel( t_aHeader, nI, TRUE )
hb_aDel( t_aHeader, nI, .T. )
ENDIF
RETURN
*/
@@ -1833,7 +1833,7 @@ STATIC FUNCTION uproc_default()
cFileName := NIL
cPathInfo := ""
DO WHILE TRUE
DO WHILE .T.
#ifdef DEBUG_ACTIVE
//hb_ToOutDebug( "cFileName = %s, cScript = %s\n\r", cFileName, cScript )
@@ -1908,7 +1908,7 @@ STATIC FUNCTION uproc_default()
// Check for PATH_INFO: I will search if there is a physical file removing parts from right
cBaseFile := cScript
lFound := FALSE
lFound := .F.
DO WHILE !Empty( cBaseFile )
//hb_toOutDebug( "cBaseFile = %s, cPathInfo = %s\n\r", cBaseFile, cPathInfo )
@@ -1922,14 +1922,14 @@ STATIC FUNCTION uproc_default()
IF HB_FileExists( uhttpd_OSFileName( _SERVER[ "DOCUMENT_ROOT" ] + cBaseFile ) )
cFileName := uhttpd_OSFileName( _SERVER[ "DOCUMENT_ROOT" ] + cBaseFile )
lFound := TRUE
lFound := .T.
EXIT
ENDIF
cFile := FileUnAlias( cBaseFile )
IF cFile != NIL .AND. HB_FileExists( uhttpd_OSFileName( cFile ) )
cFileName := uhttpd_OSFileName( cFile )
lFound := TRUE
lFound := .T.
EXIT
ENDIF
ENDDO
@@ -2235,7 +2235,7 @@ STATIC PROCEDURE WriteToConsole( ... )
RETURN
STATIC FUNCTION ParseIni( cConfig )
LOCAL hIni := hb_IniRead( cConfig, TRUE ) // TRUE = load all keys in MixedCase, redundant as it is default, but to remember
LOCAL hIni := hb_IniRead( cConfig, .T. ) // .T. = load all keys in MixedCase, redundant as it is default, but to remember
LOCAL cSection, hSect, cKey, xVal, cVal, nPos
LOCAL hDefault
@@ -2249,8 +2249,8 @@ STATIC FUNCTION ParseIni( cConfig )
"PORT" => LISTEN_PORT ,;
"APPLICATION_ROOT" => EXE_Path() ,;
"DOCUMENT_ROOT" => EXE_Path() + hb_ps() + "home" ,;
"SHOW_INDEXES" => FALSE ,;
"SCRIPTALIASMIXEDCASE" => TRUE ,;
"SHOW_INDEXES" => .F. ,;
"SCRIPTALIASMIXEDCASE" => .T. ,;
"SESSIONPATH" => EXE_Path() + hb_ps() + "sessions" ,;
"DIRECTORYINDEX" => DIRECTORYINDEX_ARRAY ,;
"CONSOLE-ROWS" => MaxRow() + 1 ,;
@@ -2267,7 +2267,7 @@ STATIC FUNCTION ParseIni( cConfig )
},;
"SCRIPTALIASES" => { => } ,;
"ALIASES" => { => } ;
}, FALSE )
}, .F. )
//hb_ToOutDebug( "hDefault = %s\n\r", hb_ValToExp( hDefault ) )
@@ -2804,7 +2804,7 @@ STATIC FUNCTION GT_notifier( nEvent, xParams )
DO CASE
CASE nEvent == HB_GTE_CLOSE
IF hb_mutexLock( s_hmtxBusy )
s_lQuitRequest := TRUE
s_lQuitRequest := .T.
nReturn := 1
hb_mutexUnlock( s_hmtxBusy )
ENDIF