Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 13 commits
  • 6 files changed
  • 1 commit comment
  • 7 contributors
2  lib/http-stream.js
View
@@ -38,7 +38,7 @@ HttpStream.prototype.pipeState = function (source) {
this.method = source.method;
if (source.url) {
- this.url = source.url;
+ this.url = this.originalUrl = source.url;
}
if (source.query) {
5 lib/request-stream.js
View
@@ -30,11 +30,14 @@ util.inherits(RequestStream, HttpStream);
// Remark: Is there anything else we wish to pipe?
//
RequestStream.prototype.pipeRequest = function (source) {
- this.url = source.url;
+ 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;
7 lib/response-stream.js
View
@@ -57,6 +57,7 @@ var ResponseStream = module.exports = function (options) {
this.response._renderHeaders = function () {
if (!self._emittedHeader) {
self._emittedHeader = true;
+ self.headerSent = true;
self.emit('header');
}
return self._renderHeaders.call(self.response);
@@ -171,8 +172,6 @@ ResponseStream.prototype.redirect = function(path, status) {
url += (path[0] === '/') ? path : '/' + path;
}
- this.res.writeHead(status || 302, {
- 'Location': url
- });
- this.res.end();
+ this.res.writeHead(status || 302, { 'Location': url });
+ this.end();
};
2  package.json
View
@@ -1,7 +1,7 @@
{
"name": "union",
"description": "A hybrid buffered / streaming middleware kernel backwards compatible with connect.",
- "version": "0.3.4",
+ "version": "0.3.7",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",
"maintainers": [
"indexzero <charlie@nodejitsu.com>",
36 test/header-test.js
View
@@ -0,0 +1,36 @@
+var assert = require('assert'),
+ request = require('request'),
+ vows = require('vows'),
+ union = require('../');
+
+vows.describe('union/header').addBatch({
+ 'When using `union`': {
+ 'with a server that responds with a header': {
+ topic: function () {
+ var callback = this.callback;
+ var server = union.createServer({
+ before: [
+ function (req, res) {
+ res.on('header', function() {
+ callback(null, res);
+ });
+ res.writeHead(200, { 'content-type': 'text' });
+ res.end();
+ }
+ ]
+ });
+ server.listen(9092, function() {
+ request('http://localhost:9092/');
+ });
+ },
+ 'it should have proper `headerSent` set': function (err, res) {
+ assert.isNull(err);
+ assert.isTrue(res.headerSent);
+ },
+ 'it should have proper `_emittedHeader` set': function (err, res) {
+ assert.isNull(err);
+ assert.isTrue(res._emittedHeader);
+ }
+ }
+ }
+}).export(module);
45 test/prop-test.js
View
@@ -0,0 +1,45 @@
+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) {
+ var net = require('net');
+
+ assert.isNull(err);
+ assert.isTrue(req.socket instanceof net.Socket);
+ }
+ }
+ }
+}).export(module);

Showing you all comments on commits in this comparison.

Charlie Robbins
Owner

wtf is wrong with me? This is still wrong.

Something went wrong with that request. Please try again.