var util = require('./util');

module.exports = function fetchFeed(delegate) {
  // delegate.url: a url string
  // delegate.verbose: a bool
  // delegate.onError: an error handler
  // delegate.onResponse: a response and data handler

  var request = util.request(delegate.url);

  request.on('error', function(e) {
    util.log(e.message);
    delegate.onError(e);
  });

  request.on('response', function(response) {
    util.log('status', response.statusCode);
    util.log('headers', JSON.stringify(response.headers));

    var data = '';
    response.setEncoding('utf8');
    response.on('data', function(chunk) {
      data += chunk;
    }).on('end', function() {
      if (delegate.verbose) { util.log('data', data); }
      delegate.onResponse(response, data);
    });
  });

  request.end();
};

@@ -518,16 +518,186 @@
 ers));%0A%0A
+    if (response.statusCode !== 200) %7B%0A      delegate.onError(%7B%0A        code: response.statusCode,%0A        message: response.statusMessage%0A      %7D);%0A      return;%0A    %7D%0A%0A
     var 

Convert non-200 fetch responses into errors