I had a similar problem with the callback never being invoked. After a little debugging I found that the problem happens when the entire HTTP response is returned in a single packet. The existing socket onRead function in Http.js either processes HTTP headers or checks for Content-Length completion, but not both, so when the entire response is returned in a single packet it never checks to see if the response is complete. I modified my Http.js so that the existing "else" block in the onRead function is instead always executed, and it works much better for me.
On Monday, August 6, 2012 11:17:36 AM UTC-4, Alexander Kohout wrote: > The callback is never invoked.. I studied the Http.js file, and I > think it should be the correct method for me - but it somehow does not > work. > > 2012/8/6 Pablo Tejada <[email protected]>: > > I haven't really mess around much with the Http class myself but i just > took > > a glance at the source on github > > > > > https://github.com/APE-Project/APE_Server/blob/master/scripts/framework/Http.js > > > > > Try the example 3, and does the callback never fires or the result is > empty? > > > > On Aug 6, 2012 10:53 AM, "Alexander Kohout" < > [email protected]> > > wrote: > >> > >> I just don't get how the HTTP class works. Using this code: > >> > >> var request = new Http('http://www.google.com/'); > >> request.getContent(function(result) { > >> Ape.log("Callback"); > >> Ape.log(result); > >> }); > >> > >> If I use the google URL (as in the example above), the callback > >> function is invoked. Any other tested URL (including my localhost > >> address) does not bring anything in the callback. So I thought: Is > >> this callback function the correct way to wait for an answer from the > >> according server? > >> > >> When I use "curl" from command line, I retrieve the correct answer > >> from my localhost, so the response should be OK - but I don't have > >> access from APE's site. > >> > >> 2012/8/6 Pablo Tejada <[email protected]>: > >> > Im a php developer myself but i've never used cakePHP so im afraid i > >> > can't > >> > help you with that, sorry > >> > > >> > On Aug 6, 2012 8:50 AM, "Alexander Kohout" > >> > <[email protected]> > >> > wrote: > >> >> > >> >> Hey Pablo, > >> >> > >> >> thanks for your answer. It gives me an idea of how to deal with the > >> >> whole > >> >> problem. But I'm currently facing a problem I don't understand: > >> >> > >> >> I don't want to make a SQL database query. Instead I want to contact > my > >> >> webserver and ask for authentication. Therefore, I thought an HTTP > >> >> request > >> >> would be the best choice and just copied the example from > >> >> server/scripts/Http.js: > >> >> > >> >> var request = new Http('http://sub.local.dev/ape/authenticate'); > >> >> request.set('method', 'POST'); > >> >> // GET or POST data > >> >> request.writeData('status', 'Hello!'); > >> >> request.getContent(function (result) { > >> >> Ape.log(result); > >> >> }); > >> >> > >> >> I'm using CakePHP on server side, so I want to invoke my ape > >> >> controller, > >> >> but the callback is somehow never invoked. Has anyone an idea what > I'm > >> >> doing > >> >> wrong here? If I enter www.google.com (as example), I get a result. > But > >> >> entering a localhost address does not return anything. > >> >> > >> >> -- > >> >> You received this message because you are subscribed to the Google > >> >> Groups "APE Project" group. > >> >> To post to this group, send email to [email protected] > >> >> To unsubscribe from this group, send email to > >> >> [email protected] > >> >> For more options, visit this group at > >> >> http://groups.google.com/group/ape-project?hl=en > >> >> --- > >> >> APE Project (Ajax Push Engine) > >> >> Official website : http://www.ape-project.org/ > >> >> Git Hub : http://github.com/APE-Project/ > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups "APE Project" group. > >> > To post to this group, send email to [email protected] > >> > To unsubscribe from this group, send email to > >> > [email protected] > >> > For more options, visit this group at > >> > http://groups.google.com/group/ape-project?hl=en > >> > --- > >> > APE Project (Ajax Push Engine) > >> > Official website : http://www.ape-project.org/ > >> > Git Hub : http://github.com/APE-Project/ > >> > >> -- > >> You received this message because you are subscribed to the Google > >> Groups "APE Project" group. > >> To post to this group, send email to [email protected] > >> To unsubscribe from this group, send email to > >> [email protected] > >> For more options, visit this group at > >> http://groups.google.com/group/ape-project?hl=en > >> --- > >> APE Project (Ajax Push Engine) > >> Official website : http://www.ape-project.org/ > >> Git Hub : http://github.com/APE-Project/ > > > > -- > > You received this message because you are subscribed to the Google > > Groups "APE Project" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group at > > http://groups.google.com/group/ape-project?hl=en > > --- > > APE Project (Ajax Push Engine) > > Official website : http://www.ape-project.org/ > > Git Hub : http://github.com/APE-Project/ > -- You received this message because you are subscribed to the Google Groups "APE Project" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/ape-project?hl=en --- APE Project (Ajax Push Engine) Official website : http://www.ape-project.org/ Git Hub : http://github.com/APE-Project/
