Hi Guys
I'm using hbhttpd contrib in my application and want shared my experience.
I attached zip with my tests.
Steps
First part
1. Run certo.bat to generate webserver 1.
2. In your browser, go to httpd://localhost:8003
3. See json content : {"Result":"OK","Field":{"codplano":"1.1.2","descricao":"REALIZAÇÕES","codpai":"1.1","___pk":"1.1.2"}}
Second part
1. Run errado.bat to generate web server 2
2. Now, go to httpd://localhost:8002
3. See content :
{"Result":"OK","Field":{"codplano":"1.1.2","descricao":"REALIZAÇÕES","codpai":"1.1","___pk":"1.1.2" <--- ERROR IN LAST CARACTERS
Conclusions (partial)
1. In example 1. I using UTF8 : REQUEST HB_CODEPAGE_UTF8
2. In example 2. I using HB_CODEPAGE_UTF8EX
3. UTF8EX doesn't work correctly in samples.
4. UTF8EX is UTF8 with BOM (I suposed). BOM is extra caracters in begin of file. This feature cause error in last characters.
5. Don't use UTF8EX in your projects with hbhttpd.
Question :
Could someone confirm these results, please?
thankful
Unfortunately I was unable to attach the examples. Only the images.
** CODE WITH ERROR (UTF8EX) / FILE ENCODED TESTED WITH UTF8 AND UTF8 WITH BOM. To work fine, replace UTF8EX with UTF8.
#require "hbhttpd"
MEMVAR server, get, post, cookie, session /* These vars is not mandatory */
REQUEST HB_CODEPAGE_UTF8EX
/****************/
PROCEDURE Main
LOCAL oServer, hConfig, hMount
hb_CdpSelect("UTF8EX")
IF hb_argCheck( "stop" )
MemoWrit( ".uhttpd.stop", "" )
RETURN
ELSEIF hb_argCheck( "start" )
? "Init server in port 8002"
? "Please type localhost:8002 in your browser"
ELSE
? "Usage: app [options]"
? "Options:"
? " //start Start server"
? " //stop Stop running server"
RETURN
ENDIF
oServer := UHttpdNew()
hMount := { => }
hMount[ "/" ] := {|| Start() }
hConfig := { ;
"FirewallFilter" => "", ;
"Port" => 8002, ;
"Trace" => {| ... | QOut( ... ) }, ;
"Idle" => {| o | iif( hb_vfExists( ".uhttpd.stop" ), ( hb_vfErase( ".uhttpd.stop" ), o:Stop() ), NIL ) }, ;
"Mount" => hMount }
IF ! oServer:Run( hConfig )
? "Server error:", oServer:cError
ErrorLevel( 1 )
RETURN
ENDIF
RETURN
/***************/
FUNCTION Start()
LOCAL cJson := '{"Result":"OK","Field":{"codplano":"1.1.2","descricao":"REALIZAÇÕES","codpai":"1.1","___pk":"1.1.2"}}'
UAddHeader( "Content-Type" , 'application/json' )
RETURN cJson
/***************/