ClosestStorm / v8cgi

Automatically exported from code.google.com/p/v8cgi
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

strage behavior of the httpclient #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I want to use v8cgi with couchdb, for this, i tryed a bit around and found
out that the http-lib behaves odd. To demonstrate what i mean i use this
snippet:

var client = new
HTTP.ClientRequest("http://localhost:5984/todo/_view/todo/textHTTP/1.1");
var response = client.send(true);

System.stdout(response.data);

The output is:
7a
{"total_rows":13,"offset":0,"rows":[
{"id":"c19a466072ec703a18318b9e3f4d5c72","key":1244906615484,"value":{"text":"ne
u"}}
57
,
{"id":"c022aaac45bfd7d81dfdfefb1f805734","key":1244906616364,"value":{"text":"ne
u"}}
57
,
{"id":"ebf771b8b3570e5ae2948cd11af3b61f","key":1244906617216,"value":{"text":"ne
u"}}
57
,
{"id":"1c18ccb948f5dc6f203af99407588ffd","key":1244906618210,"value":{"text":"ne
u"}}
57
,
{"id":"8d3886795b7c13551c31a54b22e359a1","key":1244906619287,"value":{"text":"ne
u"}}
5f
,
{"id":"b9bb8bde41bfbc4e918e888bf2b8cabe","key":1244906775615,"value":{"text":"un
d
nochwas"}}
63
,
{"id":"f36fe8cb42d91bf5b86dafd9b2ae5c5e","key":1244906779977,"value":{"text":"hu
ist das toll"}}
58
,
{"id":"9bfccb2819313665659e839882d601a0","key":1244906972932,"value":{"text":"as
df"}}
56
,
{"id":"b4276a7b8f5723f45cf4c28c2636416c","key":1244906981148,"value":{"text":"as
"}}
58
,
{"id":"484600fc40a52d2d9965368d26431684","key":1244907129650,"value":{"text":"as
df"}}
56
,
{"id":"0e26703c71689688e5e12622a56b41ef","key":1244907145332,"value":{"text":"df
"}}
58
,
{"id":"678ab07db7aec0630cb77a72d821bb60","key":1244907186776,"value":{"text":"as
df"}}
56
,
{"id":"3bb507e464ddc9a0e883f0fe7b49f32d","key":1244907331656,"value":{"text":"hj
k"}}
4

]}
0

as it sould be:
{"total_rows":13,"offset":0,"rows":[
{"id":"c19a466072ec703a18318b9e3f4d5c72","key":1244906615484,"value":{"text":"ne
u"}},
{"id":"c022aaac45bfd7d81dfdfefb1f805734","key":1244906616364,"value":{"text":"ne
u"}},
{"id":"ebf771b8b3570e5ae2948cd11af3b61f","key":1244906617216,"value":{"text":"ne
u"}},
{"id":"1c18ccb948f5dc6f203af99407588ffd","key":1244906618210,"value":{"text":"ne
u"}},
{"id":"8d3886795b7c13551c31a54b22e359a1","key":1244906619287,"value":{"text":"ne
u"}},
{"id":"b9bb8bde41bfbc4e918e888bf2b8cabe","key":1244906775615,"value":{"text":"un
d
nochwas"}},
{"id":"f36fe8cb42d91bf5b86dafd9b2ae5c5e","key":1244906779977,"value":{"text":"hu
ist das toll"}},
{"id":"9bfccb2819313665659e839882d601a0","key":1244906972932,"value":{"text":"as
df"}},
{"id":"b4276a7b8f5723f45cf4c28c2636416c","key":1244906981148,"value":{"text":"as
"}},
{"id":"484600fc40a52d2d9965368d26431684","key":1244907129650,"value":{"text":"as
df"}},
{"id":"0e26703c71689688e5e12622a56b41ef","key":1244907145332,"value":{"text":"df
"}},
{"id":"678ab07db7aec0630cb77a72d821bb60","key":1244907186776,"value":{"text":"as
df"}},
{"id":"3bb507e464ddc9a0e883f0fe7b49f32d","key":1244907331656,"value":{"text":"hj
k"}}
]}

and it is using ff as httpclient. WFT i thought. Why?
Thanks for advice.

Original issue reported on code.google.com by mkockme...@web.de on 21 Jun 2009 at 7:15

GoogleCodeExporter commented 9 years ago
Okay, this certainly is a bug. Can you please somehow (in a static version?) 
make the
data you are fetching available via a public URL, so I can use it for testing?

It looks like those strange numbers are content lengths of individual http 
response
packets. Will look into it.

Original comment by ondrej.zara on 21 Jun 2009 at 9:58

GoogleCodeExporter commented 9 years ago
More explanation: this is certainly a "chunked" transfer encoding, something not
(yet) supported by v8cgi. Will be implemented

Original comment by ondrej.zara on 21 Jun 2009 at 10:27

GoogleCodeExporter commented 9 years ago
Please try again with latest SVN revision (492). I believe I fixed this, but 
some
testing might be necessary.

Original comment by ondrej.zara on 22 Jun 2009 at 8:01

GoogleCodeExporter commented 9 years ago
hi,
thanks for such a fast reaction. After chaning the http.js file to

.
.
.
    var received = "";
    do {
        var part = s.receive(1024, true);
        for (var i=0;i<part.length;i++) {
            //received += String.fromCharCode(part[i]);
            received += part[i];
        }
    } while (part.length > 0);
    s.close();
    received = Util.utf8encode(received);

    return this._handleResponse(received, follow);
.
.
.

Everything works fine for me!
Cheers!

Original comment by mkockme...@web.de on 22 Jun 2009 at 11:49

GoogleCodeExporter commented 9 years ago
Uhm, I don't understand why you made that change to http.js. I strongly believe 
that
my version (with String.fromCharCode) is supposed to work with current SVN 
revision,
as opposed to your fix.
Have you recompiled v8cgi? This is necessary, I made an important addition to
Socket::receive method... 

Original comment by ondrej.zara on 22 Jun 2009 at 12:12

GoogleCodeExporter commented 9 years ago
sry for answering this late.

To be honest I have no idea why. But this is the only way it's works for me and 
it
works fine. I use it to communicate with CouchDB for and longer time with the 
results
I expect.

Original comment by mkockme...@web.de on 9 Sep 2009 at 3:22

GoogleCodeExporter commented 9 years ago
It would be really cool if someone could provide a tutorial about how to use 
couchDB
with v8cgi.

Original comment by lrb...@gmail.com on 4 Nov 2009 at 10:41