Changes

Jump to navigation Jump to search
1,358 bytes added ,  15:50, 16 November 2012
added restxq:response
};
</pre>
 
 
=restxq:response=
 
Since RESTXQ runs on a fully equipped Web-server, one can change all and specify more HTTP header informations that are returned to the client. By default a successful request is answered with HTTP status code "200 OK" followed by the given content, an erroneous request (due to errors in a script) with "404 Not Found" followed by the error message.
 
The first behaviour can be changed by returning an <code>restxq:response</code> element, following the [[http://expath.org/spec/http-client|EXPath HTTP Client Module]] specification. E.g. one may return to the client
 
<pre class="brush:xml">
<restxq:response>
<http:response status="418" message="I'm a teapot">
<http:header name="Content-Language" value="en"/>
<http:header name="Content-Type" value="text/html; charset=utf-8"/>
</http:response>
</restxq:response>
<html>
<body>My Message</body>
</html>
</pre>
 
Compare [http://en.wikipedia.org/wiki/List_of_HTTP_status_codes List of HTTP status codes] to see what status code fits.
It is mandatory to first place <code>restxq:response</code> followed by the content (of any kind) if any. In case of an updating function use [[Database_Module#db:output|db:output()]] to return the element and the content. If specified "Content-Type" overrides %output:media-type().
 
 
 
=Forward and Redirect=
editor, reviewer
115

edits

Navigation menu