The resource has been updated.
")) xml->sxml)) error))) (lambda () (check-precondition path if-match if-none-match etag) (respond-normal))) ;; If the precondition succeeds (if-none-match is effectively ;; invalid), we return 200 (with-exception-handler (lambda (error) (unless (precondition-failed? error) (raise-exception error)) (return (build-response #:code 304 #:reason-phrase (W_ "reason-phrase|Not Modified") #:headers (filter (lambda (h) (case (car h) ((cache-control content-location date etag expires vary) #t) (else #f))) headers)) #f '())) (lambda () (when if-none-match (check-precondition path if-match if-none-match etag)) (respond-normal))))) (define-method (handle (endpointYou are authentified, but you are not authorized to access this resource.
")) xml->sxml)) exn)) (return (build-response #:code 401 #:reason-phrase (W_ "reason-phrase|Unauthorized") #:headers `((www-authenticate . ((DPoP))))) #f '())))) ((ldp:cannot-delete-root? exn) (raise-exception (make-exception (make-web-exception 405 (W_ "reason-phrase|Method Not Allowed")) (make-user-message (call-with-input-string (format #f (W_ "The storage root cannot be deleted.
")) xml->sxml)) exn))) ((or (ldp:container-not-empty? exn) (ldp:incorrect-containment-triples? exn) (ldp:path-is-auxiliary? exn)) (raise-exception (make-exception (make-web-exception 409 (W_ "reason-phrase|Conflict")) (make-user-message (call-with-input-string (cond ((ldp:container-not-empty? exn) (format #f (W_ "You need to empty the container first before deleting it.
"))) ((ldp:incorrect-containment-triples? exn) (format #f (W_ "To change which resources are contained within this container, please use HTTP POST, PUT or DELETE.
"))) ((ldp:path-is-auxiliary? exn) (format #f (W_ "The target resource is an auxiliary resource.
")))) xml->sxml)) exn))) ((ldp:unsupported-media-type? exn) (raise-exception (make-exception (make-web-exception 415 (W_ "reason-phrase|Unsupported Media Type")) (make-user-message (call-with-input-string (format #f (W_ "You cannot use this content type.
")) xml->sxml)) exn))) ((precondition-failed? exn) (raise-exception (make-exception (make-web-exception 412 (W_ "reason-phrase|Precondition Failed")) (make-user-message (call-with-input-string (format #f (W_ "The resource is not in the state you expected.
")) xml->sxml)) exn))) ((not-acceptable? exn) (raise-exception (make-exception (make-web-exception 406 (W_ "reason-phrase|Not Acceptable")) (make-user-message (call-with-input-string (format #f (W_ "I cannot serve the resource with a content-type you want.
")) xml->sxml)) exn))) (else (raise-exception exn))))) (lambda () (case (request-method request) ((GET HEAD OPTIONS) (receive (headers content) (ldp:read (server-name endpoint) (owner endpoint) (assq-ref (request-meta request) 'user) (uri-path (request-uri request))) (let ((true-content-type (match (assq-ref headers 'content-type) ((or (? symbol? ct) ((? symbol? ct) _ ...)) ct))) (other-headers (filter (match-lambda (('content-type . _) #f) (else #t)) headers))) (receive (negociated-content-type negociated-content) (convert (request-accept request #f) (server-name endpoint) (uri-path (request-uri request)) true-content-type content) (serve-get return (uri-path (request-uri request)) (request-if-match request) (request-if-none-match request) negociated-content-type negociated-content (match (assq-ref headers 'etag) (((? string? etag) . #f) etag)) `((content-type ,negociated-content-type) ,@other-headers) (assq-ref (request-meta request) 'user)))))) ((PUT) (receive (content-type content) (nonrdf-or-turtle (server-name endpoint) request request-body) (unless content (raise-exception (make-exception (make-web-exception 400 (W_ "reason-phrase|Bad Request")) (make-user-message (call-with-input-string (format #f (W_ "Please include a request body.
")) xml->sxml))))) (let ((updated (ldp:update (server-name endpoint) (owner endpoint) (assq-ref (request-meta request) 'user) (uri-path (request-uri request)) (request-if-match request) (request-if-none-match request) content-type content))) (return (build-response #:headers `((etag . (,(ldp:etag updated) . #f)))) "" '())))) ((POST) (receive (content-type content) (nonrdf-or-turtle (server-name endpoint) request request-body) (unless content (raise-exception (make-exception (make-web-exception 400 (W_ "reason-phrase|Bad Request")) (make-user-message (call-with-input-string (format #f (W_ "Please include a request body.
")) xml->sxml))))) (let ((types (map target-iri (filter (lambda (link) (equal? (relation-type link) "type")) (request-links request))))) (return (build-response #:code 201 #:reason-phrase (W_ "reason-phrase|Created") #:headers `((location . ,(ldp:create (server-name endpoint) (owner endpoint) (assq-ref (request-meta request) 'user) (uri-path (request-uri request)) types (assq-ref (request-headers request) 'slug) content-type content)))) "" '())))) ((DELETE) (ldp:delete (server-name endpoint) (owner endpoint) (assq-ref (request-meta request) 'user) (uri-path (request-uri request)) (request-if-match request) (request-if-none-match request)) (return (build-response) "" '())))) #:unwind? #t))))