Skip to content

fix: Have AsyncHandlers only check what is necessary - #174

Merged
jvherweg merged 1 commit into
masterfrom
canHandle-checks
Oct 5, 2020
Merged

jvherweg merged 1 commit into
masterfrom
canHandle-checks

Conversation

@jvherweg

@jvherweg jvherweg commented Oct 5, 2020

Copy link
Copy Markdown
Member

Resolves #119 .

Also cleaned up some canHandle functions.

IMO it's not always clearcut when something should be in canHandle or handle, but this should solve the more clear cases.

Comment thread src/ldp/http/BasicResponseWriter.ts Outdated
@@ -12,7 +12,7 @@ export class BasicResponseWriter extends ResponseWriter {
public async canHandle(input: { response: HttpResponse; result: ResponseDescription | Error }): Promise<void> {
if (!(input.result instanceof Error)) {
if (input.result.body && !input.result.body.binary) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why double if here? (and why doesn't the linter guard this?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, actually surprised it didn't complain about this.

Comment thread src/ldp/http/BasicTargetExtractor.ts Resolved
Comment thread src/ldp/http/SparqlUpdateBodyParser.ts Outdated
const contentType = input.headers['content-type'];

if (!contentType || contentType !== 'application/sparql-update') {
if (input.headers['content-type'] !== 'application/sparql-update') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe both should be a constant (definitely the second).

@jvherweg
jvherweg merged commit 4d34cdd into master Oct 5, 2020
@jvherweg
jvherweg deleted the canHandle-checks branch October 5, 2020 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify canHandle methods check applicability, and handle throws other errors

2 participants