var fs      = require('fs')
  , request = require('request') // mikeal/request
;


function wget(options, callback) {
	if (typeof options === 'string') {
		options  = { url: options };
	}
	options      = options  || {};
	callback     = callback || function (){};
	var src      = options.url || options.uri || options.src
	  , parts    = src.split('/')
	  , file     = parts[parts.length-1]
	;
	parts        = file.split('?');
	file         = parts[0];
	parts        = file.split('#');
	file         = parts[0];
	options.dest = options.dest || './';
	if (options.dest.substr(options.dest.length-1,1) == '/') {
		options.dest = options.dest + file;
	}


	function handle_request_callback(err, res, body) {
		if (err) {
			callback(err);
		} else {
			var data = {
				filepath: options.dest
			};
			if (res && res.headers) {
				data.headers = res.headers
			}
			callback(err, data);
		}
	}


	if (options.dry) {
		handle_request_callback(null, {}, { filepath: options.dest });
		return options.dest;
	} else {
		try {
			request(options, handle_request_callback).pipe(fs.createWriteStream(options.dest));
		} catch (err) {
			callback(err);
		}
	}
}

module.exports = wget;
@@ -24,12 +24,12 @@
 fs')
+,
 %0A  
-,
  req
@@ -313,21 +313,22 @@
 ions.src
+,
 %0A%09  
-,
+ 
  parts  
@@ -349,13 +349,14 @@
 '/')
+,
 %0A%09  
-,
+ 
  fil
@@ -849,16 +849,17 @@
 .headers
+;
 %0A%09%09%09%7D%0A%09%09
@@ -877,16 +877,22 @@
 rr, data
+, body
 );%0A%09%09%7D%0A%09
@@ -1176,8 +1176,9 @@
  = wget;
+%0A

fix missing return body