When trying to PUT a multipart/form-data body, roaster will fail with an error due to missing properties, even though they are present in the body as defined in the schema.
The reason is that eXist only auto-parses multipart content in POST requests, not when they are sent by e.g. a PUT or a PATCH request. Also, request:is-multipart() is always false() in requests other than POST, even though the Content-Type is actually set as multipart-dorm-data.
The workaround is to pre-parse the multipart content and add the parameters in the controller when forwarding to roaster.
Roaster should pick this up by not assuming to find the contents of a multipart requests by a call to request:get-parameter(). We need additional handling at
like
if ( exists($schema) and request:is-multipart() ) then
…
else if ( starts-with(request:get-header('Content-Type'), 'multipart/form-data') ) then
let $parsed := someModule:parse-multipart(request:get-data(), request:get-header('Content-Type'))
map:merge(
for-each(
body:ensure-required-properties(
map:keys($parsed), $schema?required?*),
body:validate-value($schema)))
else …
and a function that produces a map out of the request data.
(I’m assuming that the parse-multipart() function returns a map of the parts, as in https://github.com/dariok/wdbplus/blob/96f2dac861834562b63364c8ebedcfd127a75172/edoc/modules/wdb-request.xqm )
When trying to
PUTamultipart/form-databody, roaster will fail with an error due to missing properties, even though they are present in the body as defined in the schema.The reason is that eXist only auto-parses
multipartcontent inPOSTrequests, not when they are sent by e.g. aPUTor aPATCHrequest. Also,request:is-multipart()is alwaysfalse()in requests other thanPOST, even though theContent-Typeis actually set asmultipart-dorm-data.The workaround is to pre-parse the multipart content and add the parameters in the controller when forwarding to roaster.Roaster should pick this up by not assuming to find the contents of a multipart requests by a call to
request:get-parameter(). We need additional handling atroaster/content/body.xqm
Line 215 in c1e9ca5
and a function that produces a map out of the request data.
(I’m assuming that the
parse-multipart()function returns a map of the parts, as in https://github.com/dariok/wdbplus/blob/96f2dac861834562b63364c8ebedcfd127a75172/edoc/modules/wdb-request.xqm )