Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9239167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:55:30+00:00 2026-06-18T07:55:30+00:00

well, i’m completely new to node.js. Starting to try it, i’m following the introduction

  • 0

well,

i’m completely new to node.js.
Starting to try it, i’m following the introduction made by Ryan Dahl (http://www.youtube.com/watch?v=jo_B4LTHi3I)
and at this point (around 0:17:00) there’s an explanation about how server handles responses,

The basic example is to have a ‘hello’ output from webserver and then after 2 secs it comes the ‘world’, this code is supposed to do that

//Require the webserver library 
var http = require('http');

var server = http.createServer(function(req, res) {
    res.writeHead(200, { 'content-type' : 'text-plain' });
    res.write('Hello\n');

    //Asynchronous behavior
    setTimeout(function() {
        res.end('World\n');
    }, 2000);
});

server.listen(3000);

So i run it, and i get the Hello World but there’s only one response from server with the complete result, that is, request > 2 sec > ‘Hello World’. Instead of request > Hello > 2 secs > World.

Why is that?, How can i change this behaviour?

I’m using v0.8.18,
curl -i http://localhost:3000 returns the right headers…
HTTP/1.1 200 OK
content-type: text-plain
Date: Sat, 26 Jan 2013 18:10:05 GMT
Connection: keep-alive
Transfer-Encoding: chunked

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:55:31+00:00Added an answer on June 18, 2026 at 7:55 am

    It is the browser that buffers the incoming data until some amount has been received, before starting to render. Your Node code does just as you expect, it will sent the first part of the response, then wait for 2 seconds, then send the second half.

    If you want to observe this behavior, you can send a bunch of spaces to make the browser empty its buffer. If you add this after your initial write, you will see the browser render the first half of the request.

    var str = '';
    for (var i = 0; i < 2000; i++){
      str += ' ';
    }
    res.write(str);
    

    Obviously don’t do this in real code, but it’s good to demonstrate the behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
Well, I downloaded Rijndael sources from here: http://www.codeproject.com/Articles/1380/A-C-Implementation-of-the-Rijndael-Encryption-Decr I have the following code: int
Well. I am new to Java. I know that main needs to be static
Well i have the following classes: Player manager (which add players, remove, etc) Player
Well, I updated my question again, totally this time. I have tested the following
Well the title says it, I'm doing following kind of operations in Fortran: a(:,t)
Well, merry christmas all! I am having trouble with the following whilst writing my
Well im new to javascript but why does this not work, all i want
Well new to the java stuff and having trouble with assigning a class attribute
Well my problem is pretty simple, i got the following includes: #include stdafx.h #include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.