Changes

Jump to navigation Jump to search
820 bytes added ,  12:25, 28 March 2015
|-
| width='120' | '''Signatures'''
|{{Func|web:response-header||element(rest:response)}}<br/>{{Func|web:response-header|$path headers as xsmap(*)|element(rest:response)}}<br/>{{Func|web:stringresponse-header|$headers as map(*), $output as map(*)|element(rest:response)}}<br/>
|-
| '''Summary'''
|Creates a [[RESTXQ#Response|RESTXQ reponse header]] for with a default caching directive and default serialization parameters.<br/>Header options can be supplied via the specified <code>$fileheaders</code> with argument. Empty string values can be specified to invalidate default values. By default, the correct mimefollowing header options will be returned:* <code>Cache-type and some caching directivesControl</code>: <code>max-age=3600,public</code><br/>Serialization parameters can be supplied via the <code>$output</code> argument. Empty string values can be specified to invalidate default values. The output By default, the following serialization parameters will only be correctly evaluated if no other items are returned before the header.:* <code>media-type</code>: <code>application/octet-stream</code>* <code>method</code>: <code>raw</code>
|-
| '''Examples'''
|If the following RESTXQ * The function is called…call <br/code><pre class="brush:xquery">declare %rest:path('image/{$image}') function local:get($image) { let $path := 'path/to/' || $image return ( web:response-header($path), file:read-binary($path) )};</precode>…an image with returns the specified name (if available) will be sent back to the clientfollowing response element:<br/>
<pre class="brush:xml">
<rest:response xmlns:rest="http://exquery.org/ns/restxq">
<http:response xmlns:http="http://expath.org/ns/http-client" status="302">
<http:header name="Cache-Control" value="max-age=3600,public"/>
</http:response>
<output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization">
<output:media-type value="imageapplication/pngoctet-stream"/>
<output:method value="raw"/>
</output:serialization-parameters>
</rest:response></pre>* If the following RESTXQ function is called by a web browser…<br/><pre class="brush:xquery">declare %rest:path('media/{$file}') function local:get($file) { let $path := 'path/to/' || $file return ( web:response-header(map { 'media-type': web:content-type($path) }),... file:read-binary($path) )};
</pre>
…a file resource with the correct content-type will be returned to user (provided that it exists in the web server's file system).
|}
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu