@@ -304,11 +304,15 @@ describe('Http Connector', function () {
304304 } ) ;
305305 } ) ;
306306
307- it ( 'collects the whole request body (compressed)' , function ( done ) {
307+ it ( 'collects the whole request body (gzip compressed)' , function ( done ) {
308308 var server = nock ( 'http://esjs.com:9200' ) ;
309309 var con = new HttpConnection ( new Host ( 'http://esjs.com:9200' ) ) ;
310- var body = '{ "USER": "doc" }' ;
311- zlib . deflate ( body , function ( err , compressedBody ) {
310+ var elements = [ ] ;
311+ for ( var i = 0 ; i < 500 ; i ++ ) {
312+ elements . push ( { "USER" : "doc" } ) ;
313+ }
314+ var body = JSON . stringify ( elements ) ;
315+ zlib . gzip ( body , function ( err , compressedBody ) {
312316 server
313317 . get ( '/users/1' )
314318 . reply ( 200 , compressedBody , { 'Content-Encoding' : 'gzip' } ) ;
@@ -326,6 +330,32 @@ describe('Http Connector', function () {
326330 } ) ;
327331 } ) ;
328332
333+ it ( 'collects the whole request body (deflate compressed)' , function ( done ) {
334+ var server = nock ( 'http://esjs.com:9200' ) ;
335+ var con = new HttpConnection ( new Host ( 'http://esjs.com:9200' ) ) ;
336+ var elements = [ ] ;
337+ for ( var i = 0 ; i < 500 ; i ++ ) {
338+ elements . push ( { "USER" : "doc" } ) ;
339+ }
340+ var body = JSON . stringify ( elements ) ;
341+ zlib . deflate ( body , function ( err , compressedBody ) {
342+ server
343+ . get ( '/users/1' )
344+ . reply ( 200 , compressedBody , { 'Content-Encoding' : 'deflate' } ) ;
345+
346+ con . request ( {
347+ method : 'GET' ,
348+ path : '/users/1'
349+ } , function ( err , resp , status ) {
350+ expect ( err ) . to . be ( undefined ) ;
351+ expect ( resp ) . to . eql ( body ) ;
352+ expect ( status ) . to . eql ( 200 ) ;
353+ server . done ( ) ;
354+ done ( ) ;
355+ } ) ;
356+ } ) ;
357+ } ) ;
358+
329359 it ( 'Can handle uncompress errors' , function ( done ) {
330360 var server = nock ( 'http://esjs.com:9200' ) ;
331361 var con = new HttpConnection ( new Host ( 'http://esjs.com:9200' ) ) ;
0 commit comments