@@ -90,6 +90,101 @@ test('download over https with custom ca', function (t) {
90
90
} )
91
91
} )
92
92
93
+ test ( 'download over http with proxy' , function ( t ) {
94
+ t . plan ( 2 )
95
+
96
+ var server = http . createServer ( function ( req , res ) {
97
+ t . strictEqual ( req . headers [ 'user-agent' ] ,
98
+ 'node-gyp v42 (node ' + process . version + ')' )
99
+ res . end ( 'ok' )
100
+ pserver . close ( function ( ) {
101
+ server . close ( )
102
+ } )
103
+ } )
104
+
105
+ var pserver = http . createServer ( function ( req , res ) {
106
+ t . strictEqual ( req . headers [ 'user-agent' ] ,
107
+ 'node-gyp v42 (node ' + process . version + ')' )
108
+ res . end ( 'proxy ok' )
109
+ server . close ( function ( ) {
110
+ pserver . close ( )
111
+ } )
112
+ } )
113
+
114
+ var host = 'localhost'
115
+ server . listen ( 0 , host , function ( ) {
116
+ var port = this . address ( ) . port
117
+ pserver . listen ( port + 1 , host , function ( ) {
118
+ var gyp = {
119
+ opts : {
120
+ proxy : 'http://' + host + ':' + ( port + 1 )
121
+ } ,
122
+ version : '42'
123
+ }
124
+ var url = 'http://' + host + ':' + port
125
+ var req = install . test . download ( gyp , { } , url )
126
+ req . on ( 'response' , function ( res ) {
127
+ var body = ''
128
+ res . setEncoding ( 'utf8' )
129
+ res . on ( 'data' , function ( data ) {
130
+ body += data
131
+ } )
132
+ res . on ( 'end' , function ( ) {
133
+ t . strictEqual ( body , 'proxy ok' )
134
+ } )
135
+ } )
136
+ } )
137
+ } )
138
+ } )
139
+
140
+ test ( 'download over http with noproxy' , function ( t ) {
141
+ t . plan ( 2 )
142
+
143
+ var server = http . createServer ( function ( req , res ) {
144
+ t . strictEqual ( req . headers [ 'user-agent' ] ,
145
+ 'node-gyp v42 (node ' + process . version + ')' )
146
+ res . end ( 'ok' )
147
+ pserver . close ( function ( ) {
148
+ server . close ( )
149
+ } )
150
+ } )
151
+
152
+ var pserver = http . createServer ( function ( req , res ) {
153
+ t . strictEqual ( req . headers [ 'user-agent' ] ,
154
+ 'node-gyp v42 (node ' + process . version + ')' )
155
+ res . end ( 'proxy ok' )
156
+ server . close ( function ( ) {
157
+ pserver . close ( )
158
+ } )
159
+ } )
160
+
161
+ var host = 'localhost'
162
+ server . listen ( 0 , host , function ( ) {
163
+ var port = this . address ( ) . port
164
+ pserver . listen ( port + 1 , host , function ( ) {
165
+ var gyp = {
166
+ opts : {
167
+ proxy : 'http://' + host + ':' + ( port + 1 ) ,
168
+ noproxy : 'localhost'
169
+ } ,
170
+ version : '42'
171
+ }
172
+ var url = 'http://' + host + ':' + port
173
+ var req = install . test . download ( gyp , { } , url )
174
+ req . on ( 'response' , function ( res ) {
175
+ var body = ''
176
+ res . setEncoding ( 'utf8' )
177
+ res . on ( 'data' , function ( data ) {
178
+ body += data
179
+ } )
180
+ res . on ( 'end' , function ( ) {
181
+ t . strictEqual ( body , 'ok' )
182
+ } )
183
+ } )
184
+ } )
185
+ } )
186
+ } )
187
+
93
188
test ( 'download with missing cafile' , function ( t ) {
94
189
t . plan ( 1 )
95
190
var gyp = {
0 commit comments