FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xHarbour issue: seeking ideas
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
xHarbour issue: seeking ideas
Posted: Thu Feb 20, 2014 08:08 PM
I am retrieving an XML document from a website using the following code:

Code (fw): Select all Collapse
       cXML := XMLtext
    oHttp:=TIpClientHttp():new("https://www.website.com" )
    oHttp:open()
    oHttp:Post( cXml)
    cRet :=  oHttp:readAll( )
    oHttp:close()


Everything works fine EXCEPT xHarbour truncates the return string stored in cRet. It reads 8192 characters ( but actually saves about half of it ). The exact same code in Harbour reads the full 22KB of return data and saves it all.

I'm using an older version ( xHarbour.com ). I'm wondering if there is any undocumented data that needs to be specified to get the full string with the xHarbour code.

I appreciate your ideas on this matter.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 01:34 AM
Tim,

It reads 8192 characters ( but actually saves about half of it ).


Please explain. Are you checking the length with len(cRet) and it returns 8192? What do you mean by it only saves half of it?

I am thinking that perhaps there is an invisible character in the middle?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 01:59 AM

This is an XML transmission. The file size is reported to be 8192 bites in length ( with the LEN( ) ) function. I save it with MemoWrit( ), and then open it in my editor. It shows on the File description that it is about 8KB in size, but only about the first 10 lines of text actually show and the rest is blank.

Now, the exact same code when using my Harbour / MSVC build reads the full XML transmission, which is about 25 KB in length.

So, either the xHarbour code sets some type of buffer limit, or times out during the transmission.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 02:53 AM
Tim,

So, either the xHarbour code sets some type of buffer limit, or times out during the transmission.


Or, it could be memowrit(), memoread(), and/or the editor you are using. Either of them could be stumbling on an unseen character.

I would process the entire string looking for non-numeric and non-alpha characters and replace them with maybe an asterisk or some other symbol.

Also, try just doing msgInfo( cRet ) without saving it.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 02:49 PM

Its not Memowrit or the editor. The data is simply being cut off by the ReadAll( ) method. The question is how to get around that with xHarbour.

The exact same data feed is being received, and read correctly, with the Harbour version.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 03:22 PM
Tim,

The data is simply being cut off by the ReadAll( ) method.


I'm sorry, I must be misunderstanding something. Are you doing:

Code (fw): Select all Collapse
cRet :=  oHttp:readAll( )
msgInfo( len( cRet) )

and the msgInfo( len( cRet ) ) returns 8192. If yes, then why are you stating the the readAll() truncates the data? Or, are you stating that the msgInfo( len(cRet) ) returns something less than 8192?

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 03:39 PM

James,

First, the actual size of the feed is about 26 KB. The entire feed is read using the ReadAll( ) in Harbour. It can then be viewed also.

Using xHarbour, only 8192 bytes are returned, and only the first half are actual characters. The rest is blanks until the EOF marker.

In translated XML terms, xHarbour returns only about 21 1/2 lines of XML text. Harbour returns the full 322 lines.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 05:05 PM

Tim,

OK, now I understand.

What version of xHarbour.com are you using? Or, rather when was it published?

Have you tried a different XML file just to see if it related to that particular file?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 06:19 PM
Tim,

The following sample works fine here using latest xHarbour from SVN and latest FWH:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oHttp

    LOCAL cRet

    oHttp = TIpClientHttp():New( "http://www.emagsoftware.it/download.htm" )

    oHttp:Open()

    cRet = oHttp:ReadAll()

    oHttp:Close()

    ? LEN( cRet )

    MEMOWRIT( "MYRESULT.TXT", cRet )

    RETURN NIL


EMG
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 06:30 PM

I'm using xHarbour.com from August 2010. That was a "for use" release ( but still called a Beta ). Since then they were mostly doing the Visual xHarbour stuff. Unfortunately I can't just swap in the latest public xHarbour ...

I'm using the more recent Harbour that Antonio provided for use with Microsoft Visual C 2012.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: xHarbour issue: seeking ideas
Posted: Fri Feb 21, 2014 06:42 PM
Tim,

TimStone wrote:I'm using xHarbour.com from August 2010.


That explains all. You can't use a four years old release and expect to not find strange behavior, don't you? :-)

EMG
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: xHarbour issue: seeking ideas
Posted: Thu Feb 27, 2014 12:49 AM

Actually, I asked and essentially got the message that not much has been done on the subscription version except for Visual xHarbour. Are you using the .com version ( with xBuilder ?

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: xHarbour issue: seeking ideas
Posted: Thu Feb 27, 2014 09:41 AM
Tim,

TimStone wrote:Actually, I asked and essentially got the message that not much has been done on the subscription version except for Visual xHarbour. Are you using the .com version ( with xBuilder ?


A lot of fixes have been done to TIp class on the official xHarbour version. As an example, I find this in the changelog that can be related to your problem:

2013-09-03 10:30 UTC-300 Luiz Rafael Culik <luiz/AT/xharbour/com/br>
* source/tip/client.prg
contrib/tipssl/client.prg
* fixed read method to allow long http response
* contrib/tipssl/httpcln.prg
* change to allow Connection: field in http header allow other values then close


EMG
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: xHarbour issue: seeking ideas
Posted: Thu Feb 27, 2014 04:26 PM

That is fine, but I would have to be a large amount of money to upgrade to the recent commercial version hoping that had been included.

I don't believe xBuild will work with anything but the .com version.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion