NETWEBGET returns strange prefix before the string

Previous topic - Next topic

adaz

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

dreamerman

In short, there is no bug, that text is just encoded with chunks.
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.
Check my source code editor for GLBasic - link Update: 20.04.2020

adaz

Quote from: dreamerman on 2018-Feb-11
In short, there is no bug, that text is just encoded with chunks.

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!

Moru

If you haven't set the headers at all, they can change because of webserver updates changing the default compression/encoding.

MrPlow

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.
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs