@@ -52,11 +52,12 @@ vows.describe('node-http-proxy/websocket').addBatch({
52
52
var that = this ;
53
53
54
54
runner . startTargetServer ( 8130 , 'hello websocket' , function ( err , target ) {
55
- var socket = io . listen ( target ) ;
55
+ var socket = io . listen ( target ) ,
56
+ headers = { } ;
56
57
57
58
socket . on ( 'connection' , function ( client ) {
58
59
client . on ( 'message' , function ( msg ) {
59
- that . callback ( null , msg ) ;
60
+ that . callback ( null , msg , headers ) ;
60
61
} ) ;
61
62
} ) ;
62
63
@@ -65,12 +66,12 @@ vows.describe('node-http-proxy/websocket').addBatch({
65
66
// Setup the web socket against our proxy
66
67
//
67
68
var ws = new websocket . WebSocket ( 'ws://localhost:8131/socket.io/websocket/' , 'borf' , {
68
- origin : 'localhost'
69
+ origin : 'http:// localhost'
69
70
} ) ;
70
71
71
72
ws . on ( 'wsupgrade' , function ( req , res ) {
72
- require ( 'eyes' ) . inspect ( req ) ;
73
- require ( 'eyes' ) . inspect ( res . headers ) ;
73
+ headers . request = req ;
74
+ headers . response = res . headers ;
74
75
} ) ;
75
76
76
77
ws . on ( 'open' , function ( ) {
@@ -79,16 +80,18 @@ vows.describe('node-http-proxy/websocket').addBatch({
79
80
} ) ;
80
81
} ) ;
81
82
} ,
82
- "the target server should receive the message" : function ( err , msg ) {
83
+ "the target server should receive the message" : function ( err , msg , headers ) {
83
84
assert . equal ( msg , 'from client' ) ;
85
+ require ( 'eyes' ) . inspect ( headers ) ;
84
86
}
85
87
} ,
86
88
"when an outbound message is sent from the target server" : {
87
89
topic : function ( ) {
88
90
var that = this ;
89
91
90
92
runner . startTargetServer ( 8132 , 'hello websocket' , function ( err , target ) {
91
- var socket = io . listen ( target ) ;
93
+ var socket = io . listen ( target ) ,
94
+ headers = { } ;
92
95
93
96
socket . on ( 'connection' , function ( client ) {
94
97
socket . broadcast ( 'from server' ) ;
@@ -99,26 +102,26 @@ vows.describe('node-http-proxy/websocket').addBatch({
99
102
// Setup the web socket against our proxy
100
103
//
101
104
var ws = new websocket . WebSocket ( 'ws://localhost:8133/socket.io/websocket/' , 'borf' , {
102
- origin : 'localhost'
105
+ origin : 'http:// localhost'
103
106
} ) ;
104
107
105
108
ws . on ( 'wsupgrade' , function ( req , res ) {
106
- require ( 'eyes' ) . inspect ( req ) ;
107
- require ( 'eyes' ) . inspect ( res . headers ) ;
109
+ headers . request = req ;
110
+ headers . response = res . headers ;
108
111
} ) ;
109
112
110
-
111
113
ws . on ( 'message' , function ( msg ) {
112
114
msg = utils . decode ( msg ) ;
113
115
if ( ! / \d + / . test ( msg ) ) {
114
- that . callback ( null , msg ) ;
116
+ that . callback ( null , msg , headers ) ;
115
117
}
116
118
} ) ;
117
119
} ) ;
118
120
} ) ;
119
121
} ,
120
- "the client should receive the message" : function ( err , msg ) {
122
+ "the client should receive the message" : function ( err , msg , headers ) {
121
123
assert . equal ( msg , 'from server' ) ;
124
+ require ( 'eyes' ) . inspect ( headers ) ;
122
125
}
123
126
}
124
127
}
0 commit comments