Skip to content
Browse files

[fix] Adding missing request properties

These properties are required if you want the `connect.logger` to work
  • Loading branch information...
1 parent ab658b0 commit 9a81ce6f28500563fa889cf847bff4d1e835ad90 @3rd-Eden 3rd-Eden committed Feb 13, 2013
Showing with 46 additions and 0 deletions.
  1. +3 −0 lib/request-stream.js
  2. +43 −0 test/prop-test.js
View
3 lib/request-stream.js
@@ -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;
View
43 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.
Something went wrong with that request. Please try again.