diff --git a/src/ldp/http/SimpleRequestParser.ts b/src/ldp/http/SimpleRequestParser.ts index 0d6edc56e..4bdbc8d29 100644 --- a/src/ldp/http/SimpleRequestParser.ts +++ b/src/ldp/http/SimpleRequestParser.ts @@ -42,9 +42,6 @@ export class SimpleRequestParser extends RequestParser { const preferences = await this.preferenceParser.handleSafe(input); const body = await this.bodyParser.handleSafe(input); - if (!input.method) { - throw new Error('Missing method.'); - } - return { method: input.method, target, preferences, body }; + return { method: input.method!, target, preferences, body }; } } diff --git a/src/ldp/operations/SimplePostOperationHandler.ts b/src/ldp/operations/SimplePostOperationHandler.ts index e09b2cde3..d65eb3edb 100644 --- a/src/ldp/operations/SimplePostOperationHandler.ts +++ b/src/ldp/operations/SimplePostOperationHandler.ts @@ -26,10 +26,7 @@ export class SimplePostOperationHandler extends OperationHandler { } public async handle(input: Operation): Promise { - if (!input.body) { - throw new UnsupportedHttpError('POST operations require a body.'); - } - const identifier = await this.store.addResource(input.target, input.body); + const identifier = await this.store.addResource(input.target, input.body!); return { identifier }; } } diff --git a/test/unit/ldp/http/SimpleRequestParser.test.ts b/test/unit/ldp/http/SimpleRequestParser.test.ts index 3104c919f..0a74f2567 100644 --- a/test/unit/ldp/http/SimpleRequestParser.test.ts +++ b/test/unit/ldp/http/SimpleRequestParser.test.ts @@ -29,10 +29,6 @@ describe('A SimpleRequestParser', (): void => { await expect(requestParser.canHandle({ url: 'url' } as any)).rejects.toThrow('Missing method.'); }); - it('errors if called without method.', async(): Promise => { - await expect(requestParser.handle({ url: 'url' } as any)).rejects.toThrow('Missing method.'); - }); - it('returns the output of all input parsers after calling handle.', async(): Promise => { await expect(requestParser.handle({ url: 'url', method: 'GET' } as any)).resolves.toEqual({ method: 'GET', diff --git a/test/unit/ldp/operations/SimplePostOperationHandler.test.ts b/test/unit/ldp/operations/SimplePostOperationHandler.test.ts index 491d9c20b..6af26f531 100644 --- a/test/unit/ldp/operations/SimplePostOperationHandler.test.ts +++ b/test/unit/ldp/operations/SimplePostOperationHandler.test.ts @@ -18,10 +18,6 @@ describe('A SimplePostOperationHandler', (): void => { await expect(handler.canHandle({ method: 'POST' } as Operation)).rejects.toThrow(UnsupportedHttpError); }); - it('errors if no body is present.', async(): Promise => { - await expect(handler.handle({ method: 'POST' } as Operation)).rejects.toThrow(UnsupportedHttpError); - }); - it('adds the given representation to the store and returns the new identifier.', async(): Promise => { await expect(handler.handle({ method: 'POST', body: { dataType: 'test' }} as Operation)) .resolves.toEqual({ identifier: { path: 'newPath' }});