HTTP Get Eaxmple?

Monkey Forums/Monkey Programming/HTTP Get Eaxmple?

CopperCircle(Posted 2013) [#1]
Hi, the GET example in Monkey V76a bananas/mak/httprequest does not seem to work? anyone else have this issue? (the example receives 0 bytes)

Thanks.


Midimaster(Posted 2013) [#2]
On which target did you test it?


CopperCircle(Posted 2013) [#3]
It was on iOS. Thanks.


DruggedBunny(Posted 2013) [#4]
Working on GLFW and my Android phone here. I did have to enable the phone's wifi first, though, as I initially got 0 bytes! Fine after that...


Midimaster(Posted 2013) [#5]
Sorry, working on Html5 and Android only...


CopperCircle(Posted 2013) [#6]
Strange, it doesn't work on HTML5 for me either?...


DruggedBunny(Posted 2013) [#7]
Hmm, on HTML5, I get 0 GET bytes and 142 POST bytes, whereas on GLFW it's 2551 GET bytes and 141 POST bytes...

I notice that the brl.httprequest docs state: "Note: The httprequest module is only available on the glfw, android, ios and html5 targets. In addition, on html5 the server must be correctly configured to accept http requests."

So perhaps the test server isn't set up for it? Not sure what the server would need though... WebSocket support maybe?


Midimaster(Posted 2013) [#8]
I develop all apps first on Html5 and then when read, I start to install and test them on the final target Android.

If I need http requests, I run Xampp on my PC and start only the "Apache" module.

Inside the Xampp dir there is a folder "htdocs". There I create a project folder (e.g. "MyProject"). Inside this I save the monkey source code (e.g. "MyApp.monkey") and run F7 to "build only".

now you can open the browser and use this url:

http://localhost/MyProject/MyApp.build/html5/MonkeyGame.html

The html5 app will now interact with the apache server and xampp.

I don't know how to say it correct, but: Html5 apps will only communicate with the server where they itself are from.


Ben(Posted 2014) [#9]
So I'm working on some of the default examples for this. Any ideas on how to do the server side in order to get the html5 version working? I've gotten the server side receiving what the client is sending but for some reason the client's post status is always 0 instead of 200. Any ideas?


CopperCircle(Posted 2014) [#10]
Hi, you need to enable cross domain on your servers header:
http://stackoverflow.com/questions/6871021/how-to-enable-cross-domain-request-on-the-server


Ben(Posted 2014) [#11]
Sweet, I got it working with node with this: res.setHeader("Access-Control-Allow-Origin", "*"); Thanks for this.