From de276ff1ecb4cb7ef8c10597e86f98f33357fc9d Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Mon, 10 Jul 2017 16:41:54 +0200 Subject: [PATCH] Fixed the HEAD method crashing when the size of a resource is undefined --- lib/server/v2/commands/Head.js | 3 ++- src/server/v2/commands/Head.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/server/v2/commands/Head.js b/lib/server/v2/commands/Head.js index eaaee678..fdad875c 100644 --- a/lib/server/v2/commands/Head.js +++ b/lib/server/v2/commands/Head.js @@ -35,7 +35,8 @@ var default_1 = (function () { ctx.setCode(WebDAVRequest_1.HTTPCodes.OK); ctx.response.setHeader('Accept-Ranges', 'bytes'); ctx.response.setHeader('Content-Type', mimeType); - ctx.response.setHeader('Content-Length', size.toString()); + if (size !== null && size !== undefined && size > -1) + ctx.response.setHeader('Content-Length', size.toString()); } callback(); }); diff --git a/src/server/v2/commands/Head.ts b/src/server/v2/commands/Head.ts index 6cfbc1e2..48a9bf6a 100644 --- a/src/server/v2/commands/Head.ts +++ b/src/server/v2/commands/Head.ts @@ -44,7 +44,8 @@ export default class implements HTTPMethod ctx.setCode(HTTPCodes.OK); ctx.response.setHeader('Accept-Ranges', 'bytes') ctx.response.setHeader('Content-Type', mimeType); - ctx.response.setHeader('Content-Length', size.toString()); + if(size !== null && size !== undefined && size > -1) + ctx.response.setHeader('Content-Length', size.toString()); } callback(); })