From 5bfb9539279a819148ea997c562b2a21329fd5c2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 24 Nov 2010 15:56:06 +0000 Subject: [PATCH] 2010-11-24 16:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbhttpd/core.prg * contrib/hbhttpd/widgets.prg * contrib/hbhttpd/tests/webapp.prg + Added :bTrace block to server class. + Changed to use bTrace block for any trace output, meaning there is no explicit '?' command anymore in server lib. --- harbour/ChangeLog | 15 ++++++++-- harbour/contrib/hbhttpd/core.prg | 38 +++++++++++++----------- harbour/contrib/hbhttpd/tests/webapp.prg | 3 +- harbour/contrib/hbhttpd/widgets.prg | 1 - 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 97d6705878..e0243f6903 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-24 16:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbhttpd/core.prg + * contrib/hbhttpd/widgets.prg + * contrib/hbhttpd/tests/webapp.prg + + Added :bTrace block to server class. + + Changed to use bTrace block for any trace output, + meaning there is no explicit '?' command anymore + in server lib. + 2010-11-24 16:11 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg ! Fixed RTE in language file generation in some side case, @@ -41,7 +50,7 @@ * Renamed. ; It's still a lie though. This is broken RDD now. If we won't have any contributor picking this up from this - stage. This contrib will be moved to examples. + stage, this contrib will be moved to examples. 2010-11-24 12:08 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) - contrib/rddbmcdx/rddbmcdx.hbp @@ -53,7 +62,7 @@ * contrib/rddbmcdx/bmdbfcdx.c * Renaming to make it index-type agnostic. * Trying to hunt down "CDX" in source code. - Huge quanity of them remain. + Huge quantity of them remain. * contrib/hbhttpd/core.prg ! Fixed unreachable code after BREAK. @@ -68,7 +77,7 @@ it doesn't build, due to interdependencies and other stuff which I don't understand. * Disabled this contrib. - ; TODO: Rename it to rddbm. + ; TODO: Rename it to rddbm. [DONE] 2010-11-24 11:23 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rdd/dbfcdx/dbfcdx1.c diff --git a/harbour/contrib/hbhttpd/core.prg b/harbour/contrib/hbhttpd/core.prg index ca7711b55a..bacccefdea 100644 --- a/harbour/contrib/hbhttpd/core.prg +++ b/harbour/contrib/hbhttpd/core.prg @@ -3,7 +3,6 @@ */ #include "hbclass.ch" -#include "common.ch" #include "error.ch" #include "hbsocket.ch" @@ -36,6 +35,7 @@ CREATE CLASS UHttpd DATA cBindAddress INIT "0.0.0.0" DATA bLogAccess INIT {|| NIL } DATA bLogError INIT {|| NIL } + DATA bTrace INIT {|| NIL } DATA bIdle INIT {|| NIL } DATA aMount INIT { => } @@ -120,8 +120,8 @@ METHOD RUN() CLASS UHttpd ENDIF ELSE hb_mutexQueueInfo( Self:hmtxQueue, @nWaiters ) - ? "New connection", hSocket - ? "Waiters:", nWaiters + Eval( Self:bTrace, "New connection", hSocket ) + Eval( Self:bTrace, "Waiters:", nWaiters ) IF nWaiters < 2 .AND. Len( aThreads ) < THREAD_COUNT_MAX /* We need two threads in worst case. If first thread becomes a sessioned @@ -203,13 +203,13 @@ STATIC FUNCTION ProcessConnection( oServer ) ELSE IF nLen == - 1 .AND. hb_socketGetError() == HB_SOCKET_ERR_TIMEOUT nLen := 0 - ? "recv() timeout", hSocket + Eval( oServer:bTrace, "recv() timeout", hSocket ) ENDIF ENDIF ENDDO IF nLen == - 1 - ? "recv() error:", hb_socketGetError() + Eval( oServer:bTrace, "recv() error:", hb_socketGetError() ) ELSEIF nLen == 0 /* connection closed */ ELSE @@ -234,7 +234,7 @@ STATIC FUNCTION ProcessConnection( oServer ) server["SERVER_PORT"] := aI[HB_SOCKET_ADINFO_PORT] ENDIF - ? Left( cRequest, At( CR_LF + CR_LF, cRequest ) + 1 ) + Eval( oServer:bTrace, Left( cRequest, At( CR_LF + CR_LF, cRequest ) + 1 ) ) nReqLen := ParseRequestHeader( @cRequest ) IF nReqLen == NIL @@ -250,10 +250,10 @@ STATIC FUNCTION ProcessConnection( oServer ) ENDDO IF nLen == - 1 - ? "recv() error:", hb_socketGetError() + Eval( oServer:bTrace, "recv() error:", hb_socketGetError() ) ELSEIF nLen == 0 /* connection closed */ ELSE - ? cRequest + Eval( oServer:bTrace, cRequest ) ParseRequestBody( Left( cRequest, nReqLen ) ) cRequest := SubStr( cRequest, nReqLen + 1 ) @@ -286,7 +286,7 @@ STATIC FUNCTION ProcessConnection( oServer ) BREAK ENDIF ENDIF - ? "Close connection1", hSocket + Eval( oServer:bTrace, "Close connection1", hSocket ) hb_socketShutdown( hSocket ) hb_socketClose( hSocket ) END SEQUENCE @@ -374,7 +374,7 @@ STATIC FUNCTION ProcessRequest( oServer, hSocket, cBuffer ) ENDIF IF Lower( UGetHeader( "Connection" ) ) == "close" .OR. server["SERVER_PROTOCOL"] == "HTTP/1.0" - ? "Close connection2", hSocket + Eval( oServer:bTrace, "Close connection2", hSocket ) hb_socketShutdown( hSocket ) hb_socketClose( hSocket ) ELSE @@ -387,7 +387,7 @@ STATIC FUNCTION ProcessRequest( oServer, hSocket, cBuffer ) ENDIF IF ! hb_mutexSubscribe( hmtx, SESSION_TIMEOUT, @aData ) .OR. aData == NIL - ? "Session exit" + Eval( oServer:bTrace, "Session exit" ) hb_mutexLock( oServer:hmtxSession ) HB_HDel( oServer:aSession, cSID ) hb_mutexUnlock( oServer:hmtxSession ) @@ -414,7 +414,7 @@ STATIC FUNCTION ProcessRequest( oServer, hSocket, cBuffer ) session := NIL ELSE /* session already exists */ - ? "session pries", server["SCRIPT_NAME"] + Eval( oServer:bTrace, "session pries", server["SCRIPT_NAME"] ) hb_mutexNotify( oServer:aSession[cSID, 2], { hSocket, cBuffer, oServer:aMount[cMount, 1], cPath, server, get, post, cookie, oServer:aSession[cSID, 3] } ) hb_mutexUnlock( oServer:hmtxSession ) ENDIF @@ -531,7 +531,7 @@ STATIC FUNCTION ParseRequestBody( cRequest ) RETURN NIL -STATIC FUNCTION MakeResponse() +STATIC FUNCTION MakeResponse( oServer ) LOCAL cRet @@ -604,7 +604,7 @@ STATIC FUNCTION MakeResponse() UAddHeader( "Content-Length", hb_ntos( Len( t_cResult ) ) ) AEval( t_aHeader, {|x| cRet += x[1] + ": " + x[2] + CR_LF } ) cRet += CR_LF - ? cRet + Eval( oServer:bTrace, cRet ) cRet += t_cResult RETURN cRet @@ -613,13 +613,13 @@ STATIC PROCEDURE SendResponse( oServer, hSocket ) LOCAL cSend, nLen - cSend := MakeResponse() + cSend := MakeResponse( oServer ) - // ? cSend + // Eval( oServer:bTrace, cSend ) DO WHILE Len( cSend ) > 0 IF ( nLen := hb_socketSend( hSocket, cSend ) ) == - 1 - ? "send() error:", hb_socketGetError(), hSocket + Eval( oServer:bTrace, "send() error:", hb_socketGetError(), hSocket ) EXIT ELSEIF nLen > 0 cSend := SubStr( cSend, nLen + 1 ) @@ -885,7 +885,9 @@ PROCEDURE UProcFiles( cFileName, lIndex ) LOCAL aDir, aF, nI, cI, tDate, tHDate - DEFAULT lIndex TO .F. + IF ! hb_isLogical( lIndex ) + lIndex := .F. + ENDIF cFileName := StrTran( cFileName, "//", "/" ) diff --git a/harbour/contrib/hbhttpd/tests/webapp.prg b/harbour/contrib/hbhttpd/tests/webapp.prg index a498070ee9..358063e3b4 100644 --- a/harbour/contrib/hbhttpd/tests/webapp.prg +++ b/harbour/contrib/hbhttpd/tests/webapp.prg @@ -2,8 +2,6 @@ * $Id$ */ -#include "simpleio.ch" - REQUEST DBFCDX MEMVAR server, get, post, cookie, session @@ -89,6 +87,7 @@ FUNCTION Main() oServer:bLogAccess := {| m | oLogAccess:Add( m + hb_eol() ) } oServer:bLogError := {| m | oLogError:Add( m + hb_eol() ) } + oServer:bTrace := {| ... | QOut( ... ) } oServer:nPort := 8002 oServer:bIdle := { |o| iif( HB_FILEEXISTS( ".uhttpd.stop" ), ( FErase(".uhttpd.stop" ), o:Stop() ), NIL ) } diff --git a/harbour/contrib/hbhttpd/widgets.prg b/harbour/contrib/hbhttpd/widgets.prg index ff81c67a9e..7e5ea3a8f9 100644 --- a/harbour/contrib/hbhttpd/widgets.prg +++ b/harbour/contrib/hbhttpd/widgets.prg @@ -491,7 +491,6 @@ PROCEDURE UProcWidgets( cURL, aMap ) LOCAL aStack, aURL, aFrame, cI, nI, nL, lRet - ? "cURL:", cURL IF HB_HHasKey( aMap, cURL ) // aStack[i] = {url_part, function, variables} IF ( aStack := hb_HGetDef( session, "_ustack" ) ) == NIL