(req, res, next)
| 4 | import debug from '../debug.mjs' |
| 5 | |
| 6 | export default async function handler (req, res, next) { |
| 7 | debug.handlers('PUT -- ' + req.originalUrl) |
| 8 | // deprecated kept for compatibility |
| 9 | res.header('MS-Author-Via', 'SPARQL') // is this needed ? |
| 10 | const contentType = req.get('content-type') |
| 11 | |
| 12 | // check whether a folder or resource with same name exists |
| 13 | try { |
| 14 | const ldp = req.app.locals.ldp |
| 15 | await ldp.checkItemName(req) |
| 16 | } catch (e) { |
| 17 | return next(e) |
| 18 | } |
| 19 | // check for valid rdf content for auxiliary resource and /profile/card |
| 20 | // TODO check that /profile/card is a minimal valid WebID card |
| 21 | if (isAuxiliary(req) || req.originalUrl === '/profile/card') { |
| 22 | if (contentType === 'text/turtle') { |
| 23 | return bodyParser.text({ type: () => true })(req, res, () => putValidRdf(req, res, next)) |
| 24 | } else return next(new HTTPError(415, 'RDF file contains invalid syntax')) |
| 25 | } |
| 26 | return putStream(req, res, next) |
| 27 | } |
| 28 | |
| 29 | // Verifies whether the user is allowed to perform Append PUT on the target |
| 30 | async function checkPermission (request, resourceExists) { |
nothing calls this directly
no test coverage detected