Skip to content

404 responses missing Accept-Patch/Accept-Put headers for PodOS compatibility #1

@melvincarvalho

Description

@melvincarvalho

Problem

PodOS/mashlib cannot create new resources because 404 responses don't include the headers that tell rdflib what editing protocols are supported.

When rdflib tries to create a new resource, it first does a GET to check if it exists. If it gets a 404 without Accept-Patch and Accept-Put headers, it doesn't know how to create the resource.

Error from PodOS:

Can't create new resources with PodOS. You may need to add accept-patch header to 404 resources, so that rdflib can figure out how to create it.
Exception in update: Error: Update: Loaded http://localhost:3210/something-new but still can't figure out what editing protocol it supports.

Solution

Add Accept-Patch, Accept-Put, and Allow headers to all 404 responses so clients know what methods are available for creating resources.

Headers added to 404 responses:

  • Accept-Patch: text/n3, application/sparql-update
  • Accept-Put: application/ld+json, text/turtle, */*
  • Allow: GET, HEAD, PUT, PATCH, OPTIONS
  • Link: <resource.acl>; rel="acl"
  • CORS headers

Affected handlers

  • handleGet - GET requests for non-existent resources
  • handleHead - HEAD requests for non-existent resources
  • handleDelete - DELETE requests for non-existent resources
  • handlePatch - PATCH requests for non-existent resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions