GLBasic forum

Main forum => Bug Reports => Topic started by: adaz on 2018-Feb-11

Title: NETWEBGET returns strange prefix before the string
Post by: adaz on 2018-Feb-11
Hi All!

Version:  15.089

NETWEBGET returns a strange prefix before the real string when I call my php from GLBasic.

You can test the php with a browser, and see the correct texts:
http://www.antirockgame.com/halloffame/score_script.php?gameid=1
or
http://www.antirockgame.com/halloffame/score_script.php?gameid=2

It's a highscore script that returns the players' names, scores and date based on gameid.

When I call it from GLBasic, there are an additional number and CR+LF before the string.
Please try it:

Code (glbasic) Select

GLOBAL halloffametemp$

halloffametemp$=NETWEBGET$("www.antirockgame.com","/halloffame/score_script.php?gameid=1",80,512)
PRINT halloffametemp$,0,120
halloffametemp$=NETWEBGET$("www.antirockgame.com","/halloffame/score_script.php?gameid=2",80,512)
PRINT halloffametemp$,0,140

SHOWSCREEN
MOUSEWAIT


I checked the db table with phpMyAdmin, and there are no "105" or "82" strings at all.

Testing with a web browser proves that the script WORKS as expected, only GLBasic returns this extra string. Why?

If you're interested, the query in the php is this:
Code (glbasic) Select

$query = "select * from scores where gameid='$gameid' order by score desc limit 10";



Thank you,
Adaz
Title: Re: NETWEBGET returns strange prefix before the string
Post by: dreamerman on 2018-Feb-11
In short, there is no bug, that text is just encoded with chunks (https://en.wikipedia.org/wiki/Chunked_transfer_encoding).
Checked with Fiddler, created raw HTTP request and response is same as in GLBasic, one of headers is: 'Transfer-Encoding: chunked', and as I assume GLB doesn't support such decoding (same with comperssion for response body) and it passes raw response body to you, so check your php code what headers are you setting, or force no encoding/compressing for that particular highscore file.

ps. in browser it will look ok as you don't see raw headers and all browser support encoding / compression.
Title: Re: NETWEBGET returns strange prefix before the string
Post by: adaz on 2018-Feb-14
Quote from: dreamerman on 2018-Feb-11
In short, there is no bug, that text is just encoded with chunks (https://en.wikipedia.org/wiki/Chunked_transfer_encoding).

The strange thing is that it's a 4 year old script, and I did not touch it at all since then. It worked that time...

But thank you very much dreamerman, I'll check that!
Title: Re: NETWEBGET returns strange prefix before the string
Post by: Moru on 2018-Feb-21
If you haven't set the headers at all, they can change because of webserver updates changing the default compression/encoding.
Title: Re: NETWEBGET returns strange prefix before the string
Post by: MrPlow on 2018-Mar-14
Web doc specs - remove all and do a basic

echo $string

inside while loop.

I have similar highscore tables on a lot of my apps.