@@ -111,7 +111,7 @@ describe('compression()', function () {
111
111
} )
112
112
} )
113
113
114
- it ( 'res.write() should throw ERR_STREAM_DESTROYED when destoyed stream' , function ( done ) {
114
+ it ( 'res.write() should throw ERR_STREAM_DESTROYED when stream is already destroyed ' , function ( done ) {
115
115
var server = createServer ( { threshold : 0 } , function ( req , res ) {
116
116
res . setHeader ( 'Content-Type' , 'text/plain' )
117
117
res . end ( 'hello world' )
@@ -131,6 +131,26 @@ describe('compression()', function () {
131
131
. expect ( 200 , done )
132
132
} )
133
133
134
+ it ( 'res.write() should throw ERR_STREAM_ALREADY_FINISHED when stream is already finished' , function ( done ) {
135
+ var server = createServer ( { threshold : 0 } , function ( req , res ) {
136
+ res . setHeader ( 'Content-Type' , 'text/plain' )
137
+ res . end ( 'hello world' )
138
+
139
+ server . on ( 'close' , function ( ) {
140
+ res . end ( function ( err ) {
141
+ assert . ok ( err . code === 'ERR_STREAM_ALREADY_FINISHED' )
142
+ } )
143
+ } )
144
+ } )
145
+
146
+ request ( server )
147
+ . get ( '/' )
148
+ . set ( 'Accept-Encoding' , 'gzip' )
149
+ . expect ( shouldHaveHeader ( 'Content-Encoding' ) )
150
+ . expect ( shouldHaveBodyLength ( 'hello world' . length ) )
151
+ . expect ( 200 , done )
152
+ } )
153
+
134
154
it ( 'res.write() should call callback if passsed' , function ( done ) {
135
155
var server = createServer ( { threshold : 0 } , function ( req , res ) {
136
156
res . setHeader ( 'Content-Type' , 'text/plain' )
0 commit comments