Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / GetHTTPResponseReady() and GetHTTPFileProgress() returned values

Author
Message
xtremi
User Offline
Joined: 26th Aug 2018
Location:
Posted: 7th Oct 2018 09:39 Edited at: 7th Oct 2018 09:41
I don't know if this is a bug or if I'm doing something wrong, but functions likeGetHTTPResponseReady() and GetHTTPFileProgress() are acting strangely.

If I setup a Host with SetHTTPHost() followed by SendHTTPRequestASync():

- If I set up correct host parameters and file on server, GetHTTPResponseReady() will return 0 on the first call, then will return 1 once it's ok. So I can use that in a loop to wait for a response.

- If I set up wrong host parameterrs or file on server. GetHTTPResponseReady() will return 1 on the first call. Is that intended? Because then calls like:
while GetHTTPResponseReady() will be useless.

The same goes for after calling GetHTTPFile():

- If parameters are correct, GetHTTPFileProgress() will return 0.0 on the first call, then increase at every call until 100.0

- If parameters are wrong, GetHTTPFileProgress() will return 100.0 on the first call.


GetHTTPFileComplete() will also return 1 even if the file was never dowloaded.

SetHTTPHost() returns 1 even if wrong parameters are given.
GetHTTPFile() returns 1 even if wrong parameters are given.



So is this working as it should be? In that case the documentation and example on for example GetHTTPFile() are very misleading.

Thanks for any feedback!
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 9th Oct 2018 18:34
I'm thinking it's probably correct, if you have an error it will immediately return as complete, but will likely be returning an error response (404 / 500 etc) instead of the data you requested. Otherwise it will never complete and just hang with no response. The key is, can you check the response code given when it returns as ready/ complete?
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
xtremi
User Offline
Joined: 26th Aug 2018
Location:
Posted: 10th Oct 2018 07:36 Edited at: 10th Oct 2018 07:37
So after making this post, I tried to the following;

(This is just a sample code with missing parameters. After work today, I will make a working example)




The thing is, it seems to act different if I run the code in Run or in Debug from Appgamekit.

If I run in Debug, with wrong http parameters, and I step through the code, it returns 0. If I run in Run, my function seem to return 1 even if I have wrong parameters, which complicates things after the function.

I will update later with a working example.
xtremi
User Offline
Joined: 26th Aug 2018
Location:
Posted: 13th Oct 2018 18:43 Edited at: 13th Oct 2018 18:44
Here is an update on my problem:

So basically what I'm trying to do;
Given that I have a host name and a server file path, host and serverfile, how can I find out if GetHTTPFile() was successful?

The code below is a complete working example:
In the MainLoop() function I set a host and serverfile.
getHTTPImageFile() is supposed to return the path of the local file to where the serverfile was downloaded. If it fails to download the image it should return an empty string.

What happens now:
- If the host and serverfile are correct it works. OK
- If the host is wrong it returns an empty string. OK
- If the host is correct but the serverfile is wrong, is still returns the local file path. NOT OK

The code:



By leaving the host and serverfile string values as they are, running this code should show a rotating picture of a forest.
By editing the host, a blue plane image should be shown.
By editing the serverfile value a default appgamekit error image will be shown. (Here I want the same blue image as when host is wrong.

If I run in Debug, and step through the code, this actually works. But running in Run mode, it does not.

Login to post a reply

Server time is: 2018-12-16 14:11:25
Your offset time is: 2018-12-16 14:11:25