var fetchUrl = function(url, callback, redirects) {
  // allow 3 redirects by default
  if(typeof(redirects) === 'undefined') {
    redirects = 3;
  }

  console.log('Fetching URL: \"' + url + '\"');

  // parse URL
  url = new URL(url);
  var client = http.createClient({
    url: url
  });
  var request = client.request('GET', url.path, {
    Host: url.host,
    Accept: 'application/rdf+xml'
  });
  request.addListener('response', function(response) {
    var body = '';

    // error, return empty body
    if(response.statusCode >= 400) {
      callback(body);
    }
    // follow redirect
    else if(response.statusCode === 302) {
      if(redirects > 0) {
        // follow redirect
        fetchUrl(response.headers.location, callback, --redirects);
      } else {
        // return empty body
        callback(body);
      }
    }
    // handle data
    else {
      response.setEncoding('utf8');
      response.addListener('data', function(chunk) {
        body += chunk;
      });
      response.addListener('end', function() {
        callback(body);
      });
    }
  });
  request.end();
};
A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.