File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,9 @@ module.exports = function httpAdapter(config) {
233
233
234
234
// Send the request
235
235
if ( utils . isStream ( data ) ) {
236
- data . pipe ( req ) ;
236
+ data . on ( 'error' , function handleStreamError ( err ) {
237
+ reject ( enhanceError ( err , config , null , req ) ) ;
238
+ } ) . pipe ( req ) ;
237
239
} else {
238
240
req . end ( data ) ;
239
241
}
Original file line number Diff line number Diff line change @@ -268,6 +268,21 @@ module.exports = {
268
268
} ) ;
269
269
} ,
270
270
271
+ testFailedStream : function ( test ) {
272
+ server = http . createServer ( function ( req , res ) {
273
+ req . pipe ( res ) ;
274
+ } ) . listen ( 4444 , function ( ) {
275
+ axios . post ( 'http://localhost:4444/' ,
276
+ fs . createReadStream ( '/does/not/exist' )
277
+ ) . then ( function ( res ) {
278
+ test . fail ( ) ;
279
+ } ) . catch ( function ( err ) {
280
+ test . equal ( err . message , 'ENOENT: no such file or directory, open \'/does/not/exist\'' ) ;
281
+ test . done ( ) ;
282
+ } ) ;
283
+ } ) ;
284
+ } ,
285
+
271
286
testBuffer : function ( test ) {
272
287
var buf = new Buffer ( 1024 ) ; // Unsafe buffer < Buffer.poolSize (8192 bytes)
273
288
buf . fill ( 'x' ) ;
You can’t perform that action at this time.
0 commit comments