BASIC

Author Topic: NETWEBGET returns strange prefix before the string  (Read 726 times)

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
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

Offline dreamerman

  • Mr. Polyvector
  • ***
  • Posts: 208
    • View Profile
    • my personal website
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.
« Last Edit: 2018-Feb-11 by dreamerman »
Check my source code editor for GLBasic - link

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
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!
« Last Edit: 2018-Feb-14 by adaz »

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1751
    • View Profile
    • Homepage
If you haven't set the headers at all, they can change because of webserver updates changing the default compression/encoding.

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1330
    • View Profile
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