Skip to content

Commit

Permalink
[fix] Adding missing request properties
Browse files Browse the repository at this point in the history
These properties are required if you want the `connect.logger` to work
  • Loading branch information
3rd-Eden committed Feb 13, 2013
1 parent ab658b0 commit 9a81ce6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/request-stream.js
Expand Up @@ -33,8 +33,11 @@ RequestStream.prototype.pipeRequest = function (source) {
this.url = this.originalUrl = source.url;
this.method = source.method;
this.httpVersion = source.httpVersion;
this.httpVersionMajor = source.httpVersionMajor;
this.httpVersionMinor = source.httpVersionMinor;
this.setEncoding = source.setEncoding;
this.connection = source.connection;
this.socket = source.socket;

if (source.query) {
this.query = source.query;
Expand Down
43 changes: 43 additions & 0 deletions test/prop-test.js
@@ -0,0 +1,43 @@
var assert = require('assert'),
request = require('request'),
vows = require('vows'),
union = require('../');

vows.describe('union/properties').addBatch({
'When using `union`': {
'with a server that responds to requests': {
topic: function () {
var callback = this.callback;
var server = union.createServer({
before: [
function (req, res) {
callback(null, req, res);

res.writeHead(200, { 'content-type': 'text' });
res.end();
}
]
});
server.listen(9092, function() {
request('http://localhost:9092/');
});
},
'the `req` should have a proper `httpVersion` set': function (err, req) {
assert.isNull(err);
assert.equal(req.httpVersion, '1.1');
},
'the `req` should have a proper `httpVersionMajor` set': function (err, req) {
assert.isNull(err);
assert.equal(req.httpVersionMajor, 1);
},
'the `req` should have a proper `httpVersionMinor` set': function (err, req) {
assert.isNull(err);
assert.equal(req.httpVersionMinor, 1);
},
'the `req` should have proper `socket` reference set': function (err, req) {
assert.isNull(err);
assert.isTrue(!!req.socket);
}
}
}
}).export(module);

0 comments on commit 9a81ce6

Please sign in to comment.