FAQ
i explained my main question in the title, but i have a problem with this
code:

var http = require('http');

var options = {
host:'google.com',
method: 'CONNECT',
path: 'google.com:80',
port: 80
};

var req = http.request(options);
req.end();

req.on('connect', function(res, socket, head) {
socket.write('GET / HTTP/1.0\r\n' +
'Host: google.com:80\r\n' +
'\r\n');
socket.on('data', function(chunk) {
console.log(chunk);
});
socket.end();
});

and i get same error:

events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1366:r20)
at TCP.onread (net.js:403:27)

you`r help, are welcome.
my english is very weak and very bad, sorry.

thanks.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

  • Dark knight at Sep 15, 2012 at 5:39 pm
    Oh my God! Sorry for my mistakes!
    my main question is: *how to create a HTTP-1.0 request by net.socket or
    http.request?*

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Ben Noordhuis at Sep 15, 2012 at 5:44 pm

    On Sat, Sep 15, 2012 at 7:38 PM, dark knight wrote:
    Oh my God! Sorry for my mistakes!
    my main question is: how to create a HTTP-1.0 request by net.socket or
    http.request?
    With net.Socket, just write the raw request.

    You can't create HTTP/1.0 requests with http.request(), it's always HTTP/1.1.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Dark knight at Sep 15, 2012 at 6:01 pm
    Thank you Ben.

    You mean that i can not create http request with net.Socket?
    ok got it.

    But on things need to be resolve, can you refactoring my code to work
    correctly in HTTP/1.1? or help to i know what's the problem?

    thanks again.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Ben Noordhuis at Sep 15, 2012 at 11:06 pm

    On Sat, Sep 15, 2012 at 8:01 PM, dark knight wrote:
    Thank you Ben.

    You mean that i can not create http request with net.Socket?
    ok got it.

    But on things need to be resolve, can you refactoring my code to work
    correctly in HTTP/1.1? or help to i know what's the problem?

    thanks again.
    I see at least one major issue with your code example:

    var options = {
    host:'google.com',
    method: 'CONNECT',
    path: 'google.com:80',
    port: 80
    };

    You are making a CONNECT request to a server that doesn't support it.
    It's going to respond with a 400 Bad Request and close the connection.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedSep 15, '12 at 4:58p
activeSep 15, '12 at 11:06p
posts5
users2
websitenodejs.org
irc#node.js

2 users in discussion

Dark knight: 3 posts Ben Noordhuis: 2 posts

People

Translate

site design / logo © 2022 Grokbase