cookie-param + restxq

Thursday, 3 May 2012 · 2 messages · last reply 6 May 2012
AB
Andy Bunce3 May 2012 22:22 #
There seems to be problem with cookie-param when the cookie is NOT set. The error is [XPDY0002] No value assigned to $c. See code below for an example. I understand the restxq stuff is in development/experimental and I wonder what plans you have in that direction? I think there are issues/limitations with the url limited to restxq/ and that xqm can be accessed directly (as text) etc, but one limitation of the spec seems to be that one can read a named header or cookie ( chosen at design time ) but not list all headers in the request. I wonder if an extension to get the full serialization of the request in the http:send-request response format might be useful. e.g. %rest:request("{$req}") /Andy
declare %rest:path("/showcookie")
%output:method("xhtml")
%rest:cookie-param("abc","{$c}","a")
%rest:query-param("answer", "{$answer}", 42, 43, 44)
function test:showcookie($c,$answer)
 {
         <rest:response>
           <http:response status="200" />
       </rest:response>,
       <div>showcookie *{$c}*
       <div>answer *{$answer}*</div>
       </div>
};

declare %rest:path("/redirect2")
%output:method("xhtml")
function test:redirect2()
 {
         <rest:response>
           <http:response status="301" >
             <http:header name="Location" value="
http://localhost:8984/restxq/showcookie"/>
              <http:header name="Set-Cookie" value="abc=cookme"/>
           </http:response>
       </rest:response>
};
CG
Christian Grün6 May 2012 18:43 #
Quoted text · Andy Bunce · 5 lines
> There seems to be problem with cookie-param when the cookie is NOT set. The > error is > > [XPDY0002] No value assigned to $c. > See code below for an example.
Thanks Andy; I have fixed this issue and updated the code (if the problem persists.. your feedback is welcome).

⚡Generated with XQuery