Problem with HTTP client request and a server I have no control over...

33 views
Skip to first unread message

TooTallNate

unread,
Aug 17, 2010, 3:40:43 PM8/17/10
to nodejs
Hey guys, I'm attempting to perform a simple HTTP request against a
remote server that I have no control over whatsoever. I'm expecting
the request to return a 302 redirect to another URL, but instead Node
keeps on crashing on me when trying to parse the response:

events:12
throw arguments[1];
^
Error: Parse Error
at Client.ondata (http:881:22)
at IOWatcher.callback (net:517:29)
at node.js:773:9


Here's the code I'm trying. Almost a copy & paste of the google
example on the API page:
http://gist.github.com/531588

I am able to paste the URL into Chrome and it redirects to the
expected URL.

I am thinking that this is happening due to a sloppy response from the
server (I noticed that there's a bunch of spaces after a bunch of the
header values before the \r\n), and that possibly Node should be a bit
more lenient about this kind of response so that the coder can do
something with it.

Also, I know that the response it coming back ok because I can see it
and it's 302 status and it's redirected URL through Wireshark, but
Node it choking while parsing it seems. Thanks in advance!

sdocherty

unread,
Aug 17, 2010, 3:54:01 PM8/17/10
to nodejs
wget http://gist.github.com/raw/531588/d90046ed7868c44e20329b66fbfc61a7ea9e7fb7/redir.js
node redir.js
STATUS: 302

seemed ok for me...
also added

console.log(JSON.stringify(response.headers));

in order to confirm your statement about sloppy response...which I'd
probably agree to...but it works for me...
node v0.0.102 compiled from source with openssl on Ubuntu 10.04 x86

Ben Noordhuis

unread,
Aug 17, 2010, 4:23:48 PM8/17/10
to nod...@googlegroups.com
Latest from GH, Ubuntu 10.04 on x86_64.

$ ../node redir.js

events:12
throw arguments[1];
^
Error: Parse Error

at Client.ondata (http:882:22)
at IOWatcher.callback (net:494:29)
at node.js:760:9

TooTallNate

unread,
Aug 17, 2010, 4:46:10 PM8/17/10
to nodejs
Interesting, perhaps it's something that broke recently. I'm using
"v0.1.104" and it's crashing, but "v0.1.102" is apparently working for
sdocherty (I haven't tested this myself).

Anyways, I've started a GitHub Issue describing what's happening, so
hopefully it will get sorted out shortly!
<http://github.com/ry/node/issues/issue/242>
Reply all
Reply to author
Forward
0 new messages