Page 1 of 1

tIpClientHttp bug

Posted: Thu Nov 03, 2016 5:38 pm
by Marco Turco
Hi all,
I noted a problem downloading a text file through tipclienthttp oHttp:Readall:
it is a 200 rows text file and some rows contains spur characters but only on Windows XP,Vista, 7, all is right on Windows 8/10.
Is there something wrong on my code or do I have to upgrade my xharbour libs ?
I'm using xHarbour with FWH Sept 2015 and BCC7.0

oUrl := TURL():New( "my http url")
oHttp:= TIpClientHttp():new( oUrl, .f. )
IF .NOT. oHttp:open()
? "Connection error:", oHttp:lastErrorMessage()
QUIT
ENDIF
cHtml := oHttp:readAll() && cHtml contains spur characters
oHttp:close()

Thank you in advance

Re: tIpClientHttp bug

Posted: Thu Nov 03, 2016 6:04 pm
by karinha

Code: Select all

/* TIP HTTP advanced operations test */

#require "hbssl"
#require "hbtip"

#if ! defined( __HBSCRIPT__HBSHELL )
REQUEST __HBEXTERN__HBSSL__
#endif

PROCEDURE Main( cURL )

 LOCAL oHTTP, oURL, i

 IF Empty( oURL := TUrl():New( cURL ) )
   ? "Invalid URL", cURL
   RETURN
 ENDIF

 IF !( oURL:cProto == "http" ) .AND. ;
   !( oURL:cProto == "https" )
   ? "This is a header test for http/https."
   ? "Use an http/https address."
   RETURN
 ENDIF

 IF oURL:cProto == "https" .AND. ! tip_SSL()
   ? "Error: Requires SSL support"
   RETURN
 ENDIF

 oHTTP := TIPClientHTTP():New( oURL )
 oHTTP:nConnTimeout := 20000
 ? "Connecting with", oURL:cServer
 IF oHTTP:Open( cURL )
   ? "Connection eshtablished"
   ? "Retrieving", oURL:cPath, oURL:cFile, oURL:cQuery

   IF oHTTP:Get( oURL:cPath )
    ? "Get Successful"
    FOR EACH i IN oHTTP:hHeaders
      ? i:__enumKey() + ":", i
    NEXT
   ELSE
    ? "Get failure (server reply:", oHTTP:cReply, ")"
   ENDIF

   oHTTP:Close()
 ELSE
   ? "Can't connect with", oURL:cServer
   IF oHTTP:SocketCon == NIL
    ? "Connection not initiated"
   ELSEIF hb_inetErrorCode( oHTTP:SocketCon ) == 0
    ? "Server replied:", oHTTP:cReply
   ELSE
    ? "Error in connection:", hb_inetErrorDesc( oHTTP:SocketCon )
   ENDIF
 ENDIF

 ? "Done"

 RETURN

 

Re: tIpClientHttp bug

Posted: Thu Nov 03, 2016 6:06 pm
by karinha