Skip to content

Commit

Permalink
Setting request Content-Length
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 9, 2010
1 parent ee34d16 commit bdd0f3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/app.js
Expand Up @@ -89,6 +89,8 @@ var wizard = [
},

post: function(req, res){
console.log(req.headers);
console.log(req.body);
req.session.wizard.city = req.body.city;
res.redirect('/wizard/page/2');
}
Expand Down
6 changes: 5 additions & 1 deletion lib/browser.js
Expand Up @@ -107,7 +107,6 @@ Browser.prototype.request = function(method, path, options, fn, saveHistory){
++server.pending;

// HTTP client
// TODO: options for headers, request body etc
if (!server.fd) {
server.listen(++port, host);
server.client = http.createClient(port);
Expand All @@ -120,6 +119,11 @@ Browser.prototype.request = function(method, path, options, fn, saveHistory){
var cookies = this.cookieJar.cookieString({ url: path });
if (cookies) headers.Cookie = cookies;

// Request body
if (options.body) {
headers['Content-Length'] = options.body.length;
}

// Request
headers.Host = host;
var req = server.client.request(method, path, headers);
Expand Down

0 comments on commit bdd0f3c

Please sign in to comment.