Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( 'should be possible to POST not yet ended stream-data', async ( ) =>
{
const stream = through2( );
const eventual_response = fetch(
'https://nghttp2.org/httpbin/post',
{
method: 'POST',
body: new StreamBody( stream ),
headers: { 'content-length': '6' },
}
);
await delay( 1 );
stream.write( "foo" );
stream.write( "bar" );
stream.end( );
const response = await eventual_response;
const data = await response.json( );
expect( data.data ).to.equal( "foobar" );
} );
wrapContext( async ( fetch ) =>
{
const stream = through2( );
const eventualResponse = fetch(
`${host}/post`,
{
allowForbiddenHeaders: true,
body: new StreamBody( stream ),
headers: { "content-length": "6" },
method: "POST",
}
);
await delay( 1 );
stream.write( "foo" );
stream.write( "bar" );
stream.end( );
const response = await eventualResponse;
const data = await response.json( );
expect( data.data ).toBe( "foobar" );
} ) );