@@ -109,14 +109,28 @@ describe('publishing endpoints', () => {
109109 expectBucketHasProfile ( profileToken ) ;
110110 } ) ;
111111
112+ it ( 'also works for length between 50MB and 150MB' , async ( ) => {
113+ const payload = gzipSync ( `{"foo": "${ '#' . repeat ( 55 * 1024 * 1024 ) } "}` , {
114+ level : 0 ,
115+ } ) ;
116+ const req = getPreconfiguredRequest ( ) ;
117+ await req
118+ . set ( 'Content-Length' , String ( payload . length ) )
119+ . send ( payload )
120+ . expect ( 200 ) ;
121+ } ) ;
122+
112123 it ( 'returns an error when the length header is too big' , async ( ) => {
113124 jest
114125 . spyOn ( process . stdout , 'write' )
115126 . mockImplementation ( ( _ : string | Uint8Array ) => true ) ;
116127 const req = getPreconfiguredRequest ( ) ;
117128 await req
118129 . set ( 'Content-Length' , String ( 1024 * 1024 * 1024 ) )
119- . expect ( 413 , / T h e l e n g t h i s b i g g e r t h a n t h e c o n f i g u r e d m a x i m u m / ) ;
130+ . expect (
131+ 413 ,
132+ / T h e r e c e i v e d l e n g t h \d + i s b i g g e r t h a n t h e c o n f i g u r e d m a x i m u m /
133+ ) ;
120134 expect ( process . stdout . write ) . toHaveBeenCalledWith (
121135 expect . stringContaining ( 'server_error' )
122136 ) ;
@@ -131,8 +145,8 @@ describe('publishing endpoints', () => {
131145 // When using the low-level API "write", Node generates a "chunked encoding"
132146 // request without a Content-Length. This is exactly what we want to check
133147 // here.
134- // We generate a Buffer of ~51MB , but our limit is 50MB .
135- const payload = gzipSync ( `{"foo": "${ '#' . repeat ( 51 * 1024 * 1024 ) } "}` , {
148+ // We generate a Buffer of ~151MB , but our limit is 150MB .
149+ const payload = gzipSync ( `{"foo": "${ '#' . repeat ( 151 * 1024 * 1024 ) } "}` , {
136150 level : 0 ,
137151 } ) ;
138152 await req . write ( payload ) ;
0 commit comments