blob: 5e47bccc6f2d3c71dde17e94f87f66a3d29ced37 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: odata/handler</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: odata/handler</h1>
<section>
<header>
<h2>
odata/handler
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line21">line 21</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="contentType"><span class="type-signature">&lt;inner> </span>contentType<span class="signature">(str)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Parses a string into an object with media type and properties.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">String with media type to parse.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line38">line 38</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
null if the string is empty; an object with 'mediaType' and a 'properties' dictionary otherwise.
</div>
</dd>
<dt>
<h4 class="name" id="contentTypeToString"><span class="type-signature">&lt;inner> </span>contentTypeToString<span class="signature">(contentType)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Serializes an object with media type and properties dictionary into a string.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>contentType</code></td>
<td class="type">
</td>
<td class="description last">Object with media type and properties dictionary to serialize.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line60">line 60</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
String representation of the media type object; undefined if contentType is null or undefined.
</div>
</dd>
<dt>
<h4 class="name" id="createReadWriteContext"><span class="type-signature">&lt;inner> </span>createReadWriteContext<span class="signature">(contentType, dataServiceVersion, context, handler)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Creates an object that is going to be used as the context for the handler's parser and serializer.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>contentType</code></td>
<td class="type">
</td>
<td class="description last">Object with media type and properties dictionary.</td>
</tr>
<tr>
<td class="name"><code>dataServiceVersion</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">String indicating the version of the protocol to use.</td>
</tr>
<tr>
<td class="name"><code>context</code></td>
<td class="type">
</td>
<td class="description last">Operation context.</td>
</tr>
<tr>
<td class="name"><code>handler</code></td>
<td class="type">
</td>
<td class="description last">Handler object that is processing a resquest or response.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line80">line 80</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Context object.
</div>
</dd>
<dt>
<h4 class="name" id="fixDataServiceVersionHeader"><span class="type-signature">&lt;inner> </span>fixDataServiceVersionHeader<span class="signature">(request, version)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Sets the DataServiceVersion header of the request if its value is not yet defined or of a lower version.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>request</code></td>
<td class="type">
</td>
<td class="description last">Request object on which the header will be set.</td>
</tr>
<tr>
<td class="name"><code>version</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Version value. If the request has already a version value higher than the one supplied the this function does nothing.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line114">line 114</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="fixRequestHeader"><span class="type-signature">&lt;inner> </span>fixRequestHeader<span class="signature">(request, name, value)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Sets a request header's value. If the header has already a value other than undefined, null or empty string, then this method does nothing.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>request</code></td>
<td class="type">
</td>
<td class="description last">Request object on which the header will be set.</td>
</tr>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Header name.</td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Header value.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line98">line 98</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="getContentType"><span class="type-signature">&lt;inner> </span>getContentType<span class="signature">(requestOrResponse)</span><span class="type-signature"> &rarr; {Object}</span></h4>
</dt>
<dd>
<div class="description">
Gets the value of the Content-Type header from a request or response.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>requestOrResponse</code></td>
<td class="type">
</td>
<td class="description last">Object representing a request or a response.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line138">line 138</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object with 'mediaType' and a 'properties' dictionary; null in case that the header is not found or doesn't have a value.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="getDataServiceVersion"><span class="type-signature">&lt;inner> </span>getDataServiceVersion<span class="signature">(requestOrResponse)</span><span class="type-signature"> &rarr; {String}</span></h4>
</dt>
<dd>
<div class="description">
Gets the value of the DataServiceVersion header from a request or response.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>requestOrResponse</code></td>
<td class="type">
</td>
<td class="description last">Object representing a request or a response.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line148">line 148</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Data service version; undefined if the header cannot be found.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="getRequestOrResponseHeader"><span class="type-signature">&lt;inner> </span>getRequestOrResponseHeader<span class="signature">(requestOrResponse, name)</span><span class="type-signature"> &rarr; {String}</span></h4>
</dt>
<dd>
<div class="description">
Gets the value of a request or response header.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>requestOrResponse</code></td>
<td class="type">
</td>
<td class="description last">Object representing a request or a response.</td>
</tr>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Name of the header to retrieve.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line128">line 128</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
String value of the header; undefined if the header cannot be found.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="handler"><span class="type-signature">&lt;inner> </span>handler<span class="signature">(parseCallback, serializeCallback, accept, maxDataServiceVersion)</span><span class="type-signature"> &rarr; {Object}</span></h4>
</dt>
<dd>
<div class="description">
Creates a handler object for processing HTTP requests and responses.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>parseCallback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Parser function that will process the response payload.</td>
</tr>
<tr>
<td class="name"><code>serializeCallback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Serializer function that will generate the request payload.</td>
</tr>
<tr>
<td class="name"><code>accept</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">String containing a comma separated list of the mime types that this handler can work with.</td>
</tr>
<tr>
<td class="name"><code>maxDataServiceVersion</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">String indicating the highest version of the protocol that this handler can work with.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line244">line 244</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Handler object.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="handlerAccepts"><span class="type-signature">&lt;inner> </span>handlerAccepts<span class="signature">(handler, cType)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
</dt>
<dd>
<div class="description">
Checks that a handler can process a particular mime type.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>handler</code></td>
<td class="type">
</td>
<td class="description last">Handler object that is processing a resquest or response.</td>
</tr>
<tr>
<td class="name"><code>cType</code></td>
<td class="type">
</td>
<td class="description last">Object with 'mediaType' and a 'properties' dictionary.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line169">line 169</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if the handler can process the mime type; false otherwise. The following check isn't as strict because if cType.mediaType = application/; it will match an accept value of "application/xml"; however in practice we don't not expect to see such "suffixed" mimeTypes for the handlers.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="handlerRead"><span class="type-signature">&lt;inner> </span>handlerRead<span class="signature">(handler, parseCallback, response, context)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
</dt>
<dd>
<div class="description">
Invokes the parser associated with a handler for reading the payload of a HTTP response.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>handler</code></td>
<td class="type">
</td>
<td class="description last">Handler object that is processing the response.</td>
</tr>
<tr>
<td class="name"><code>parseCallback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Parser function that will process the response payload.</td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
</td>
<td class="description last">HTTP response whose payload is going to be processed.</td>
</tr>
<tr>
<td class="name"><code>context</code></td>
<td class="type">
</td>
<td class="description last">Object used as the context for processing the response.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line180">line 180</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if the handler processed the response payload and the response.data property was set; false otherwise.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="handlerWrite"><span class="type-signature">&lt;inner> </span>handlerWrite<span class="signature">(handler, serializeCallback, request, context)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
</dt>
<dd>
<div class="description">
Invokes the serializer associated with a handler for generating the payload of a HTTP request.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>handler</code></td>
<td class="type">
</td>
<td class="description last">Handler object that is processing the request.</td>
</tr>
<tr>
<td class="name"><code>serializeCallback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Serializer function that will generate the request payload.</td>
</tr>
<tr>
<td class="name"><code>request</code></td>
<td class="type">
</td>
<td class="description last">HTTP request whose payload is going to be generated.</td>
</tr>
<tr>
<td class="name"><code>context</code></td>
<td class="type">
</td>
<td class="description last">Object used as the context for serializing the request.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="handler.js.html">odata/handler.js</a>, <a href="handler.js.html#line211">line 211</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if the handler serialized the request payload and the request.body property was set; false otherwise.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-cache.html">cache</a></li><li><a href="source.html">cache/source</a></li><li><a href="module-odata.html">odata</a></li><li><a href="batch.html">odata/batch</a></li><li><a href="handler.html">odata/handler</a></li><li><a href="json.html">odata/json</a></li><li><a href="metadata.html">odata/metadata</a></li><li><a href="net.html">odata/net</a></li><li><a href="utils.html">odata/utils</a></li><li><a href="deferred.html">odatajs/deferred</a></li><li><a href="utils_.html">odatajs/utils</a></li><li><a href="xml.html">odatajs/xml</a></li><li><a href="module-store.html">store</a></li><li><a href="dom.html">store/dom</a></li><li><a href="indexeddb.html">store/indexeddb</a></li><li><a href="memory.html">store/memory</a></li></ul><h3>Classes</h3><ul><li><a href="DataCache.html">DataCache</a></li><li><a href="DataCacheOperation.html">DataCacheOperation</a></li><li><a href="DjsDeferred.html">DjsDeferred</a></li><li><a href="dom-DomStore.html">DomStore</a></li><li><a href="indexeddb-IndexedDBStore.html">IndexedDBStore</a></li><li><a href="memory-MemoryStore.html">MemoryStore</a></li><li><a href="ODataCacheSource.html">ODataCacheSource</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Thu Apr 09 2015 08:31:26 GMT+0200 (MESZ)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>