@@ -2252,3 +2252,50 @@ it.skip("should be able to stream huge amounts of data", async () => {
2252
2252
server . close ( ) ;
2253
2253
}
2254
2254
} , 30_000 ) ;
2255
+
2256
+ // TODO: today we use a workaround to continue event, we need to fix it in the future.
2257
+ it ( "should emit continue event #7480" , done => {
2258
+ let receivedContinue = false ;
2259
+ const req = request (
2260
+ "https://example.com" ,
2261
+ { headers : { "accept-encoding" : "identity" , "expect" : "100-continue" } } ,
2262
+ res => {
2263
+ let data = "" ;
2264
+ res . setEncoding ( "utf8" ) ;
2265
+ res . on ( "data" , chunk => {
2266
+ data += chunk ;
2267
+ } ) ;
2268
+ res . on ( "end" , ( ) => {
2269
+ expect ( receivedContinue ) . toBe ( true ) ;
2270
+ expect ( data ) . toContain ( "This domain is for use in illustrative examples in documents" ) ;
2271
+ done ( ) ;
2272
+ } ) ;
2273
+ res . on ( "error" , err => done ( err ) ) ;
2274
+ } ,
2275
+ ) ;
2276
+ req . on ( "continue" , ( ) => {
2277
+ receivedContinue = true ;
2278
+ } ) ;
2279
+ req . end ( ) ;
2280
+ } ) ;
2281
+
2282
+ it ( "should not emit continue event #7480" , done => {
2283
+ let receivedContinue = false ;
2284
+ const req = request ( "https://example.com" , { headers : { "accept-encoding" : "identity" } } , res => {
2285
+ let data = "" ;
2286
+ res . setEncoding ( "utf8" ) ;
2287
+ res . on ( "data" , chunk => {
2288
+ data += chunk ;
2289
+ } ) ;
2290
+ res . on ( "end" , ( ) => {
2291
+ expect ( receivedContinue ) . toBe ( false ) ;
2292
+ expect ( data ) . toContain ( "This domain is for use in illustrative examples in documents" ) ;
2293
+ done ( ) ;
2294
+ } ) ;
2295
+ res . on ( "error" , err => done ( err ) ) ;
2296
+ } ) ;
2297
+ req . on ( "continue" , ( ) => {
2298
+ receivedContinue = true ;
2299
+ } ) ;
2300
+ req . end ( ) ;
2301
+ } ) ;
0 commit comments