Module: odata/handler

odata/handler

Methods

<inner> contentType(str)

Parses a string into an object with media type and properties.
Parameters:
Name Type Description
str String String with media type to parse.
Source:
Returns:
null if the string is empty; an object with 'mediaType' and a 'properties' dictionary otherwise.

<inner> contentTypeToString(contentType)

Serializes an object with media type and properties dictionary into a string.
Parameters:
Name Type Description
contentType Object with media type and properties dictionary to serialize.
Source:
Returns:
String representation of the media type object; undefined if contentType is null or undefined.

<inner> createReadWriteContext(contentType, dataServiceVersion, context, handler)

Creates an object that is going to be used as the context for the handler's parser and serializer.
Parameters:
Name Type Description
contentType Object with media type and properties dictionary.
dataServiceVersion String String indicating the version of the protocol to use.
context Operation context.
handler Handler object that is processing a resquest or response.
Source:
Returns:
Context object.

<inner> fixDataServiceVersionHeader(request, version)

Sets the DataServiceVersion header of the request if its value is not yet defined or of a lower version.
Parameters:
Name Type Description
request Request object on which the header will be set.
version String Version value. If the request has already a version value higher than the one supplied the this function does nothing.
Source:

<inner> fixRequestHeader(request, name, value)

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.
Parameters:
Name Type Description
request Request object on which the header will be set.
name String Header name.
value String Header value.
Source:

<inner> getContentType(requestOrResponse) → {Object}

Gets the value of the Content-Type header from a request or response.
Parameters:
Name Type Description
requestOrResponse Object representing a request or a response.
Source:
Returns:
Object with 'mediaType' and a 'properties' dictionary; null in case that the header is not found or doesn't have a value.
Type
Object

<inner> getDataServiceVersion(requestOrResponse) → {String}

Gets the value of the DataServiceVersion header from a request or response.
Parameters:
Name Type Description
requestOrResponse Object representing a request or a response.
Source:
Returns:
Data service version; undefined if the header cannot be found.
Type
String

<inner> getRequestOrResponseHeader(requestOrResponse, name) → {String}

Gets the value of a request or response header.
Parameters:
Name Type Description
requestOrResponse Object representing a request or a response.
name String Name of the header to retrieve.
Source:
Returns:
String value of the header; undefined if the header cannot be found.
Type
String

<inner> handler(parseCallback, serializeCallback, accept, maxDataServiceVersion) → {Object}

Creates a handler object for processing HTTP requests and responses.
Parameters:
Name Type Description
parseCallback function Parser function that will process the response payload.
serializeCallback function Serializer function that will generate the request payload.
accept String String containing a comma separated list of the mime types that this handler can work with.
maxDataServiceVersion String String indicating the highest version of the protocol that this handler can work with.
Source:
Returns:
Handler object.
Type
Object

<inner> handlerAccepts(handler, cType) → {Boolean}

Checks that a handler can process a particular mime type.
Parameters:
Name Type Description
handler Handler object that is processing a resquest or response.
cType Object with 'mediaType' and a 'properties' dictionary.
Source:
Returns:
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.
Type
Boolean

<inner> handlerRead(handler, parseCallback, response, context) → {Boolean}

Invokes the parser associated with a handler for reading the payload of a HTTP response.
Parameters:
Name Type Description
handler Handler object that is processing the response.
parseCallback function Parser function that will process the response payload.
response HTTP response whose payload is going to be processed.
context Object used as the context for processing the response.
Source:
Returns:
True if the handler processed the response payload and the response.data property was set; false otherwise.
Type
Boolean

<inner> handlerWrite(handler, serializeCallback, request, context) → {Boolean}

Invokes the serializer associated with a handler for generating the payload of a HTTP request.
Parameters:
Name Type Description
handler Handler object that is processing the request.
serializeCallback function Serializer function that will generate the request payload.
request HTTP request whose payload is going to be generated.
context Object used as the context for serializing the request.
Source:
Returns:
True if the handler serialized the request payload and the request.body property was set; false otherwise.
Type
Boolean