Skip to content

Commit

Permalink
merge in headers from opts
Browse files Browse the repository at this point in the history
  • Loading branch information
pkrumins committed Oct 14, 2010
1 parent 6272c9c commit 6a4a41d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions browser.js
Expand Up @@ -2,6 +2,7 @@ var http = require('http');
var parse = require('url').parse;
var EventEmitter = require('events').EventEmitter;
var BufferList = require('bufferlist').BufferList;
var Hash = require('traverse/hash');

module.exports = Browser;
function Browser () {
Expand Down Expand Up @@ -34,13 +35,15 @@ function Browser () {

opts = opts || {};
opts.method = opts.method || 'GET';
opts.headers = opts.headers || {};

var parsed = parse(url);
var client = http.createClient(parsed.port || 80, parsed.hostname);
var path = (parsed.pathname || '/') + (parsed.search || '');
var request = client.request(opts.method, path, {
var headers = Hash({
host : parsed.hostname
});
}).merge(opts.headers).items;
var request = client.request(opts.method, path, headers);
request.end(opts.data || '');
var data = new BufferList;
request.on('response', function (response) {
Expand Down

0 comments on commit 6a4a41d

Please sign in to comment.