Hi all,

I probably should have signed up with gitHub and submitted a bug report but 
hope this will at least help someone.

When using a GET request the /framework/http.js is not sending the 
querystring params specified with writeData.
It looks like the author meant it to, i.e. a variable is set with any 
querystring params but it is never written out to the socket.

Lines 105-113 in http.js
Originally :
if (this.body.length != 0 && this.method == 'GET') {
    var getData = '';

    if (this.method == 'GET') {
        getData = '?' + this.body.join('&');
    }
}

var toWrite = this.method + " " + this.query + " HTTP/1.0\r\nHost: " + 
this.host + "\r\n";


My solution :
var getData = '';
if (this.body.length != 0 && this.method == 'GET') {
    if (this.method == 'GET') {
        getData = '?' + this.body.join('&');
    }
}

var toWrite = this.method + " " + this.query + getData + " 
HTTP/1.0\r\nHost: " + this.host + "\r\n";

Ape Code to test with:
Ape.registerHookCmd("connect", function(params, cmd) { 
    var request = new Http('http://yourserver/yourfile.php'); 
    //Querystring params
    request.writeData('var1', 'foo');
    request.writeData('var2', 'baa');

    request.getContent(function(result) { //response from the PHP file 
        Ape.log('result=' + result); 
    });
});

//Note: To verify what was being sent as the HTTP request I added the 
following line to Http.js @line=120
Ape.log(toWrite + "\r\n");

Example PHP code to run on the web server (yourserver) to confirm 
querystring params are being received :
<?php
foreach ($_GET as $key => $value) {
    print "<br>$key is $value \n";
}
?>


Expected HTTP request given example above :
GET /yourfile.php?var1=foo&var2=baa HTTP/1.0
Host: yourserver
User-Agent: APE JS Client
Accept: */*


Hope that helps.
I also wanted to say thanks to the authors of APE and http.js, nice work :)

Cheers

Jeff





-- 
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/

Reply via email to