Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Have AsyncHandlers only check what is necessary #174

Merged
merged 1 commit into from
Oct 5, 2020

Conversation

joachimvh
Copy link
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.

@@ -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
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
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.

src/ldp/http/BasicTargetExtractor.ts Show resolved Hide resolved
const contentType = input.headers['content-type'];

if (!contentType || contentType !== 'application/sparql-update') {
if (input.headers['content-type'] !== 'application/sparql-update') {
Copy link
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).

@joachimvh joachimvh merged commit 4d34cdd into master Oct 5, 2020
@joachimvh joachimvh 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