Page 1 of 1
HttpRequest doesn´t work
Posted: 21 Dec 2012, 16:51
by Jojo_44
Hey,
I´m trying the new httprequest with Beta 2.0 but my Code doesn´t work:
Code: Select all
#Include "TextLib" as TextLib
declare CHttpRequest shoutbox;
Void getXMLFromWeb() {
shoutbox = Http.CreateGet("http://localhost/Maniascript/httptest/shoutbox.xml");
while(!shoutbox.IsCompleted) {
}
log(shoutbox.Result);
}
Void preventBug() {
}
main() {
getXMLFromWeb();
}
Maniaplanet says that the script consumes too many resources. What´s wrong with my code ?
regards, Jojo
Re: HttpRequest doesn't work
Posted: 21 Dec 2012, 18:37
by m4rcel
Same problem for me, I also tried to request some data, but it seems not working in Manialink context.
My script:
Code: Select all
log("Test start");
log("Valid: " ^ Http.IsValidUrl("http://localhost/test/getXML"));
log("Slots: " ^ Http.SlotsAvailable);
declare CHttpRequest Request = Http.CreateGet("http://localhost/test/getXML");
log("Slots: " ^ Http.SlotsAvailable);
declare Integer Next = Now + 1000;
while (True) {
while (Now < Next) {
yield;
}
if (Request.IsCompleted) {
log("Request Completed, Status: " ^ Request.StatusCode);
log(Request.Result);
break;
} else {
log("Waiting for Request... Status: " ^ Request.StatusCode);
Next += 1000;
yield;
}
}
The URL is proofed to be valid, and the slots are decreased with each script call, but yet I was unable to see the request in the network traffic., So the request seems to be actually never started. (Thus, the script of course keeps in the loop printing "Waiting for Request", status is always 0. )
Re: HttpRequest doesn´t work
Posted: 22 Dec 2012, 22:01
by steeffeen
for me the httprequest worked fine, i tried it during a created multiplayer game (not on a dedicated server)
btw: i suggest
for the first test of a http request, so you don't need any loops or something like that
Re: HttpRequest doesn´t work
Posted: 23 Dec 2012, 10:03
by m4rcel
steeffeen wrote:for me the httprequest worked fine, i tried it during a created multiplayer game (not on a dedicated server)
btw: i suggest
for the first test of a http request, so you don't need any loops or something like that
This was my first test, with the result, that the Browser did not respond anymore (as of never finishing the request). So I replaced it with the loop to have some debug output
And it is good to know that it works for servers, so it may be a bug in the Manialink browser.
Re: HttpRequest doesn´t work
Posted: 05 Jan 2013, 12:24
by spaii