File tree 3 files changed +41
-6
lines changed
3 files changed +41
-6
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,16 @@ module.exports = ForwardStream;
21
21
*/
22
22
23
23
function ForwardStream ( ) {
24
+ var self = this ;
25
+
24
26
Writable . call ( this ) ;
25
27
26
- this . once ( 'pipe' , this . onPipe ) ;
27
- this . once ( 'finish' , this . onFinish ) ;
28
+ this . once ( 'pipe' , function ( ) { self . onPipe ( ) } ) ;
29
+ this . once ( 'finish' , function ( ) { self . onFinish ( ) } ) ;
28
30
}
29
31
32
+ require ( 'util' ) . inherits ( ForwardStream , Writable ) ;
33
+
30
34
/**
31
35
* Fires up the request to the external target
32
36
*
@@ -74,6 +78,4 @@ ForwardStream.prototype.onFinish = function() {
74
78
75
79
ForwardStream . prototype . _write = function ( chunk , encoding , clb ) {
76
80
this . forwardReq . write ( chunk , encoding , clb ) ;
77
- } ;
78
-
79
- require ( 'util' ) . inherits ( ForwardStream , Writable ) ;
81
+ } ;
Original file line number Diff line number Diff line change 19
19
},
20
20
"scripts" : {
21
21
"blanket" : { "pattern" : " caronte/lib" },
22
- "test" : " mocha -R spec test/*-test.js && npm run-script test-cov " ,
22
+ "test" : " mocha -R landing test/*-test.js" ,
23
23
"test-cov" : " mocha --require blanket -R html-cov > cov/coverage.html"
24
24
},
25
25
Original file line number Diff line number Diff line change
1
+ var common = require ( '../lib/caronte/common' ) ,
2
+ expect = require ( 'expect.js' ) ;
3
+
4
+ describe ( 'lib/caronte/common.js' , function ( ) {
5
+ describe ( '#setupOutgoing' , function ( ) {
6
+ it ( 'should setup the right headers' , function ( ) {
7
+ var outgoing = { } ;
8
+ common . setupOutgoing ( outgoing ,
9
+ {
10
+ host : 'hey' ,
11
+ hostname : 'how' ,
12
+ socketPath : 'are' ,
13
+ port : 'you' ,
14
+ agent : '?'
15
+ } ,
16
+ {
17
+ method : 'i' ,
18
+ path : 'am' ,
19
+ headers : 'proxy'
20
+ } ) ;
21
+
22
+ expect ( outgoing . host ) . to . eql ( 'hey' ) ;
23
+ expect ( outgoing . hostname ) . to . eql ( 'how' ) ;
24
+ expect ( outgoing . socketPath ) . to . eql ( 'are' ) ;
25
+ expect ( outgoing . port ) . to . eql ( 'you' ) ;
26
+ expect ( outgoing . agent ) . to . eql ( '?' ) ;
27
+
28
+ expect ( outgoing . method ) . to . eql ( 'i' ) ;
29
+ expect ( outgoing . path ) . to . eql ( 'am' ) ;
30
+ expect ( outgoing . headers ) . to . eql ( 'proxy' )
31
+ } ) ;
32
+ } ) ;
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments