Make strictContentLength option default to true 路 sindresorhus/got@08e9dff (original) (raw)

Original file line number Diff line number Diff line change
@@ -396,6 +396,7 @@ test('errors have body', withServer, async (t, server, got) => {
396 396 });
397 397
398 398 const error = await t.throwsAsync<RequestError>(getStream(got.stream('', {
399 +strictContentLength: false,
399 400 cookieJar: {
400 401 async setCookie() {
401 402 throw new Error('snap');
@@ -678,7 +679,7 @@ test('does not throw when content-length header is absent', withServer, async (t
678 679 t.is(body, 'hello');
679 680 });
680 681
681 -test('throws generic abort error (not content-length error) when strictContentLength is false (default)', withServer, async (t, server, got) => {
682 +test('throws content-length mismatch error by default', withServer, async (t, server, got) => {
682 683 server.get('/', (_request, response) => {
683 684 response.writeHead(200, {
684 685 'content-length': '100',
@@ -691,8 +692,7 @@ test('throws generic abort error (not content-length error) when strictContentLe
691 692 got('').text(),
692 693 {
693 694 instanceOf: RequestError,
694 -// Should get generic abort error, not content-length specific error
695 -message: /aborted pending request/,
695 +message: /Content-Length mismatch/,
696 696 },
697 697 );
698 698 });