Changes

Jump to navigation Jump to search
250 bytes added ,  10:40, 17 October 2017
no edit summary
==web:response-header==
 
{{Mark|Updated with Version 9.0}}: third argument added; no default parameters.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|web:response-header||element(rest:response)}}<br/>{{Func|web:response-header|$output as map(*)|element(rest:response)}}<br/>{{Func|web:response-header|$output as map(*), $headers as map(*)|element(rest:response)}}<br/>{{Func|web:response-header|$output as map(*), $headers as map(*), $atts as map(*)|element(rest:response)}}<br/>
|-
| '''Summary'''
|Creates a [[RESTXQ#Response|RESTXQ response header]] with a default caching directive and default serialization parameters.<br/>Serialization parameters and header values can be supplied via the <code>$output</code> argument. Empty string values and <code>$headers</code> arguments, and status and message attributes can be specified attached to invalidate default valuesthe top element with the <code>$atts</code> argument. By default, the following serialization parameters will be returned:
* <code>media-type</code>: <code>application/octet-stream</code>
Header options can be supplied via the <code>$headers</code> argument. Empty string values can be specified to invalidate default values. By default, the following header options will be returned:
| '''Examples'''
|
* The function call <code>web:response-header()</code> returns the following response element:
<pre class="brush:xml">
<rest:response xmlns:rest="http://exquery.org/ns/restxq">
<http:response xmlns:http="http://expath.org/ns/http-client"> <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="application/octet-stream"/> </output:serialization-parameters>
</rest:response>
</pre>
* If The following function returns a media-type for binary data, a caching directive, and the OK status:<br/><pre class="brush:xquery">web:response-header( map { 'media-type': 'application/octet-stream' }, map { 'Cache-Control': 'max-age=3600,public' }, map { 'status': 200, 'message': 'OK' })</pre>* The following RESTXQ function is called by returns the contents of a web browser…file to the client with correct media type:<br/>
<pre class="brush:xquery">
declare %rest:path('media/{$file}') function local:get($file) {
};
</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).
|}
=Changelog=
 
;Version 9.0
 
* Updated: [[#web:response-header|web:response-header]]: third argument; no default parameters.
;Version 8.4
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu