Skip to content

Commit

Permalink
fix(core): Fixed validation check of content-encoded responses
Browse files Browse the repository at this point in the history
Closes #27
  • Loading branch information
grantila committed Jan 9, 2019
1 parent eee97c0 commit 8336256
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ export class Response extends Body
{
const contentType = headers.get( HTTP2_HEADER_CONTENT_TYPE );
const contentLength = headers.get( HTTP2_HEADER_CONTENT_LENGTH );
const contentEncoding =
headers.get( HTTP2_HEADER_CONTENT_ENCODING );

const length =
contentLength == null
( contentLength == null || contentEncoding != null )
? null
: parseInt( contentLength, 10 );

Expand Down
7 changes: 7 additions & 0 deletions test/fetch-h2/nghttp2.org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,11 @@ describe( "nghttp2.org/httpbin", function( )

await disconnectAll( );
} );

it( "should be possible to GET gzip data", async ( ) =>
{
const response = await fetch( "https://nghttp2.org/httpbin/gzip" );
const data = await response.json( );
expect( data ).to.deep.include( { gzipped: true, method: "GET" } );
} );
} );

0 comments on commit 8336256

Please sign in to comment.