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

  • SEARCH
  • Home
  • 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 7893055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:01:31+00:00 2026-06-03T07:01:31+00:00

I am playing around vows and nodejs. var vows = require(‘vows’); var http =

  • 0

I am playing around vows and nodejs.

var vows = require('vows');
var http = require('http');
var suite = vows.describe('testing');
var host = 'www.google.com', port = '80', path = '/', method = 'GET';

suite.addBatch({
    'A context': {
        topic: function(){
            http.get({
              host: host,
              port: port,
              path: path,
              method: method
            }, this.callback);
        },
        "sample test": function(res, extra){//here extra is just to prevent vows error
            res.on('data', function (chunk) {
                console.log('BODY: ' + chunk);//It never gets logged
            });
            console.log('HEADERS: ' + JSON.stringify(res.headers));//it is working
        }
    }
});

suite.export(module);

But I am unable to get the response body. What am I doing wrong.

I am using nodejs v 0.6.6 and vows v0.6.2

  • 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-03T07:01:33+00:00Added an answer on June 3, 2026 at 7:01 am

    From what I can see, it looks like Vows doesn’t directly invoke the test when this.callback runs. It is delayed by processnextTick. If I had to guess, maybe the ‘data’ event is being emitted during that time. That means you don’t bind your ‘data’ function until after all the data events have been triggered.

    Really though, the issue is that Vows tests are supposed to separate all async logic like this into the topic itself. If you really want to check the chunks in a test, then do it like this.

    Also note that you can have any number of chunks, there isn’t just a single data event. You may want to set the stream encoding, and join the data as strings. Your current code implicitly converts a Buffer to string, which can break for multi-byte characters.

    suite.addBatch({
        'A context': {
            topic: function(){
                var cb = this.callback;
                var req = http.get({
                  host: host,
                  port: port,
                  path: path,
                  method: method
                });
    
                // Aggregate all chunks before running callback
                req.on('response', function(res) {
                  var chunks = []
                  res.on('data', function(chunk) {
                    chunks.push(chunk);
                  });
                  res.on('end', function() {
                    cb(null, res, chunks);
                  });
                });
    
                // Handle connection failures.
                req.on('error', cb);
            },
            "sample test": function(err, res, chunks){
                chunks.forEach(function (chunk, i) {
                    console.log('BODY piece ' + i + ': ' + chunk);
                });
                console.log('HEADERS: ' + JSON.stringify(res.headers));
            }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Playing around with Google Maps these days, with some directions. I have a map
Playing around with Python - tkInter - Entry widget - when I use validatecommand
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
been playing around with ResolveClientUrl(~/Confirmation.aspx) and other methods.. I am tryin go get the
I playing around with the Twitter API for my BlackBerry application. Is there any
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>
Been playing around with this for a couple of hours and can't seem to
Was playing around a little bit with the TimeSpan class and I started wondering
Just playing around with memcache for the first time; here's my code: $memcache =
I've been playing around with different methods of determining at runtime the width of

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.