2009-04-30 18:49 UTC+0200 Francesco Saverio Giudice (info/at/fsgiudice.com)
* harbour/examples/httpsrv/uhttpd.prg
* Added some hb_ToOutDebug() points garded from DEBUG_ACTIVE define
for debugging purpose
* harbour/examples/httpsrv/modules/showcounter.prg
* harbour/examples/httpsrv/modules/tableservletdb.prg
* fixed path for current directory
as now define all _SERVER variables
* harbour/examples/httpsrv/cookie.prg
* fixed error on deleting cookie
This commit is contained in:
@@ -17,6 +17,17 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-04-30 18:49 UTC+0200 Francesco Saverio Giudice (info/at/fsgiudice.com)
|
||||
* harbour/examples/httpsrv/uhttpd.prg
|
||||
* Added some hb_ToOutDebug() points garded from DEBUG_ACTIVE define
|
||||
for debugging purpose
|
||||
* harbour/examples/httpsrv/modules/showcounter.prg
|
||||
* harbour/examples/httpsrv/modules/tableservletdb.prg
|
||||
* fixed path for current directory
|
||||
as now define all _SERVER variables
|
||||
* harbour/examples/httpsrv/cookie.prg
|
||||
* fixed error on deleting cookie
|
||||
|
||||
2009-07-30 12:00 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbwin/Makefile
|
||||
+ contrib/hbwin/hbsim.ch
|
||||
|
||||
@@ -106,7 +106,7 @@ METHOD SetCookie( cCookieName, xValue, cDomain, cPath, cExpires, lSecure, lHttpO
|
||||
|
||||
::lHttpOnly := lHttpOnly
|
||||
|
||||
IF !Empty( xValue )
|
||||
IF xValue != NIL
|
||||
// Search if a cookie already exists
|
||||
// case sensitive
|
||||
IF ( nPos := aScan( ::aCookies, {|e| e[ 1 ] == cCookieName } ) ) > 0
|
||||
|
||||
@@ -60,10 +60,10 @@ MEMVAR _REQUEST // defined in uHTTPD
|
||||
#include "gd.ch"
|
||||
|
||||
#ifdef __PLATFORM__UNIX
|
||||
#define IMAGES_IN "../../hbgd/tests/digits/"
|
||||
#define IMAGES_IN "../../../contrib/hbgd/tests/digits/"
|
||||
#define IMAGES_OUT ( _SERVER[ "DOCUMENT_ROOT" ] + "/counter/" )
|
||||
#else
|
||||
#define IMAGES_IN "..\..\hbgd\tests\digits\"
|
||||
#define IMAGES_IN "..\..\..\contrib\hbgd\tests\digits\"
|
||||
#define IMAGES_OUT ( _SERVER[ "DOCUMENT_ROOT" ] + "\counter\" )
|
||||
#endif
|
||||
|
||||
@@ -114,6 +114,8 @@ STATIC FUNCTION CreateCounter( cValue, cBaseImage )
|
||||
//hb_ToOutDebug( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' not found" )
|
||||
//THROW( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' not found" )
|
||||
RETURN NIL
|
||||
//ELSE
|
||||
// hb_ToOutDebug( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' FOUND" )
|
||||
ENDIF
|
||||
|
||||
nValue := Val( cValue )
|
||||
|
||||
@@ -55,9 +55,9 @@
|
||||
|
||||
#define CRLF ( chr(13)+chr(10) )
|
||||
#ifdef __PLATFORM__WINDOWS
|
||||
#define TABLE_NAME_PATH "..\..\..\..\tests\test.dbf"
|
||||
#define TABLE_NAME_PATH "..\..\..\tests\test.dbf"
|
||||
#else
|
||||
#define TABLE_NAME_PATH "../../../../tests/test.dbf"
|
||||
#define TABLE_NAME_PATH "../../../tests/test.dbf"
|
||||
#endif
|
||||
#define SIMULATE_SLOW_REPLY
|
||||
|
||||
@@ -157,11 +157,15 @@ RETURN Self
|
||||
METHOD Open() CLASS TableManager
|
||||
LOCAL cDBF := ::cTable
|
||||
|
||||
//hb_ToOutDebug( "CurPath = %s", CurDrive() + hb_osDriveSeparator() + HB_OSPathSeparator() + CurDir() )
|
||||
|
||||
//hb_ToOutDebug( "before: cDBF = %s, Used() = %s\n", cDBF, Used() )
|
||||
|
||||
IF !::lOpened
|
||||
|
||||
CLOSE ALL
|
||||
USE ( cDBF ) ALIAS table SHARED NEW
|
||||
//hb_ToOutDebug( "cDBF = %s, Used() = %s\n", cDBF, Used() )
|
||||
//hb_ToOutDebug( "after: cDBF = %s, Used() = %s\n", cDBF, Used() )
|
||||
::lOpened := USED()
|
||||
|
||||
ENDIF
|
||||
|
||||
@@ -454,7 +454,9 @@ FUNCTION MAIN( ... )
|
||||
RETURN 3
|
||||
ENDIF
|
||||
|
||||
//hb_ToOutDebug( "s_cDocumentRoot = %s, cDocumentRoot = %s\n\r", s_cDocumentRoot, cDocumentRoot )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "s_cDocumentRoot = %s, cDocumentRoot = %s\n\r", s_cDocumentRoot, cDocumentRoot )
|
||||
#endif
|
||||
|
||||
IF HB_ISSTRING( cDocumentRoot )
|
||||
//cI := STRTRAN( SUBSTR( cDocumentRoot, 2 ), "\", "/" )
|
||||
@@ -476,7 +478,9 @@ FUNCTION MAIN( ... )
|
||||
RETURN 3
|
||||
ENDIF
|
||||
|
||||
//hb_ToOutDebug( "s_cDocumentRoot = %s, cDocumentRoot = %s\n\r", s_cDocumentRoot, cDocumentRoot )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "s_cDocumentRoot = %s, cDocumentRoot = %s\n\r", s_cDocumentRoot, cDocumentRoot )
|
||||
#endif
|
||||
|
||||
IF nMaxThreads <= 0
|
||||
nMaxThreads := MAX_RUNNING_THREADS
|
||||
@@ -585,8 +589,9 @@ FUNCTION MAIN( ... )
|
||||
WriteToConsole( "Starting AcceptConnection Thread" )
|
||||
aThreads := {}
|
||||
AADD( aThreads, hb_threadStart( @AcceptConnections() ) )
|
||||
//hb_ToOutDebug( "Len( aThreads ) = %i\n\r", Len( aThreads ) )
|
||||
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "Len( aThreads ) = %i\n\r", Len( aThreads ) )
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------------- //
|
||||
// main loop
|
||||
@@ -880,7 +885,9 @@ STATIC FUNCTION ProcessConnection()
|
||||
|
||||
nThreadId := hb_threadID()
|
||||
|
||||
//hb_ToOutDebug( "nThreadId = %s\r\n", nThreadId )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "nThreadId = %s\r\n", nThreadId )
|
||||
#endif
|
||||
|
||||
ErrorBlock( { | oError | uhttpd_DefError( oError ) } )
|
||||
|
||||
@@ -956,6 +963,10 @@ STATIC FUNCTION ProcessConnection()
|
||||
/* receive query */
|
||||
nLen := readRequest( hSocket, @cRequest )
|
||||
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "cRequest -- BEGIN --\n\r%s\n\rcRequest -- END --\n\r", cRequest )
|
||||
#endif
|
||||
|
||||
IF nLen == -1
|
||||
#ifdef USE_HB_INET
|
||||
? "recv() error:", hb_InetErrorCode( hSocket ), hb_InetErrorDesc( hSocket )
|
||||
@@ -986,7 +997,9 @@ STATIC FUNCTION ProcessConnection()
|
||||
cSend := MakeResponse()
|
||||
ENDIF
|
||||
|
||||
//hb_ToOutDebug( "cSend = %s\n\r", cSend )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "cSend = %s\n\r", cSend )
|
||||
#endif
|
||||
|
||||
sendReply( hSocket, cSend )
|
||||
|
||||
@@ -1196,7 +1209,9 @@ STATIC FUNCTION ParseRequest( cRequest )
|
||||
// RFC2616
|
||||
aRequest := uhttpd_split( CR_LF, cRequest )
|
||||
|
||||
//hb_ToOutDebug( "aRequest = %s\n\r", hb_ValToExp( aRequest ) )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "aRequest = %s\n\r", hb_ValToExp( aRequest ) )
|
||||
#endif
|
||||
|
||||
WriteToConsole( aRequest[1] )
|
||||
aLine := uhttpd_split( " ", aRequest[1] )
|
||||
@@ -1333,13 +1348,15 @@ STATIC FUNCTION ParseRequest( cRequest )
|
||||
_SERVER[ "SCRIPT_URL" ] := _SERVER[ "SCRIPT_NAME" ]
|
||||
_SERVER[ "SCRIPT_URI" ] := "http://" + _HTTP_REQUEST[ "HOST" ] + _SERVER[ "SCRIPT_NAME" ]
|
||||
|
||||
//hb_ToOutDebug( "_SERVER = %s\n\r", hb_ValToExp( _SERVER ) )
|
||||
//hb_ToOutDebug( "_GET = %s\n\r", hb_ValToExp( _GET ) )
|
||||
//hb_ToOutDebug( "_POST = %s\n\r", hb_ValToExp( _POST ) )
|
||||
//hb_ToOutDebug( "_COOKIE = %s\n\r", hb_ValToExp( _COOKIE ) )
|
||||
//hb_ToOutDebug( "_SESSION = %s\n\r", hb_ValToExp( _SESSION ) )
|
||||
//hb_ToOutDebug( "_HTTP_REQUEST = %s\n\r", hb_ValToExp( _HTTP_REQUEST ) )
|
||||
//hb_ToOutDebug( "_HTTP_RESPONSE = %s\n\r", hb_ValToExp( _HTTP_RESPONSE ) )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "_SERVER = %s\n\r", hb_ValToExp( _SERVER ) )
|
||||
hb_ToOutDebug( "_GET = %s\n\r", hb_ValToExp( _GET ) )
|
||||
hb_ToOutDebug( "_POST = %s\n\r", hb_ValToExp( _POST ) )
|
||||
hb_ToOutDebug( "_COOKIE = %s\n\r", hb_ValToExp( _COOKIE ) )
|
||||
hb_ToOutDebug( "_SESSION = %s\n\r", hb_ValToExp( _SESSION ) )
|
||||
hb_ToOutDebug( "_HTTP_REQUEST = %s\n\r", hb_ValToExp( _HTTP_REQUEST ) )
|
||||
hb_ToOutDebug( "_HTTP_RESPONSE = %s\n\r", hb_ValToExp( _HTTP_RESPONSE ) )
|
||||
#endif
|
||||
|
||||
// After defined all SERVER vars we can define a session
|
||||
// SESSION - sessions ID is stored as a cookie value, normally as SESSIONID var name (this can be user defined)
|
||||
@@ -1793,7 +1810,9 @@ STATIC FUNCTION readRequest( hSocket, /* @ */ cRequest )
|
||||
nContLen := 0
|
||||
DO WHILE /* AT( CR_LF + CR_LF, cRequest ) == 0 .AND. */ nRcvLen > 0
|
||||
cBuf := hb_InetRecvLine( hSocket, @nRcvLen )
|
||||
//hb_ToOutDebug( " nRcvLen = %i, cBuf = %s \n\r", nRcvLen, cBuf )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "readRequest(): nRcvLen = %i, cBuf = %s \n\r", nRcvLen, cBuf )
|
||||
#endif
|
||||
IF nRcvLen > 0
|
||||
cRequest += cBuf + CR_LF
|
||||
nLen += nRcvLen
|
||||
@@ -1804,7 +1823,9 @@ STATIC FUNCTION readRequest( hSocket, /* @ */ cRequest )
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
//hb_ToOutDebug( " nLen = %i, nContLen = %i \n\r", nLen, nContLen )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "readRequest(): nLen = %i, nContLen = %i \n\r", nLen, nContLen )
|
||||
#endif
|
||||
// if the request has a content-lenght, we must read it
|
||||
IF nLen > 0 .AND. nContLen > 0
|
||||
// cPostData is autoAllocated
|
||||
@@ -1820,11 +1841,16 @@ STATIC FUNCTION readRequest( hSocket, /* @ */ cRequest )
|
||||
nLen := 1
|
||||
DO WHILE AT( CR_LF + CR_LF, cRequest ) == 0 .AND. nLen > 0
|
||||
nLen := socket_recv( hSocket, @cBuf )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "readRequest(): nLen = %i, cBuf = %s \n\r", nLen, cBuf )
|
||||
#endif
|
||||
cRequest += cBuf
|
||||
ENDDO
|
||||
#endif
|
||||
|
||||
//hb_ToOutDebug( " nLen = %i, cRequese = %s \n\r", nLen, cRequest )
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "readRequest(): nLen = %i, cRequest = %s \n\r", nLen, cRequest )
|
||||
#endif
|
||||
|
||||
RETURN nLen
|
||||
|
||||
@@ -2802,6 +2828,11 @@ STATIC FUNCTION Handler_HrbScript( cFileName )
|
||||
|
||||
xResult := HRBMAIN()
|
||||
|
||||
#ifdef DEBUG_ACTIVE
|
||||
hb_ToOutDebug( "Handler_HrbScript(): cFileName = %s,\n\rcCurPath = %s,\n\rs_cDocumentRoot = %s,\n\rpHRB = %s,\n\rxResult = %s\n\r", ;
|
||||
cFileName, cCurPath, s_cDocumentRoot, pHRB, xResult )
|
||||
#endif
|
||||
|
||||
// return to original folder
|
||||
DirChange( cCurPath )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user