Made to Order Software Corporation Logo

LLChatLib: LLHTTPNode Class Reference

LLHTTPNode Class Reference

Base class which handles url traversal, response routing and support for standard LLSD services. More...

#include <llhttpnode.h>

Inheritance diagram for LLHTTPNode:

List of all members.

Public Member Functions

virtual const LLChainIOFactorygetProtocolHandler () const
Child Nodes

The standard node can have any number of child nodes under fixed names, and optionally one "wildcard" node that can handle all other names.

Usually, child nodes are add through LLHTTPRegistration, not by calling this interface directly.

The added node will be now owned by the parent node.

virtual void addNode (const std::string &path, LLHTTPNode *nodeToAdd)
LLSD allNodePaths () const
 Returns an arrary of node paths at and under this node.

const LLHTTPNodefindNode (const std::string &name) const
const LLHTTPNoderootNode () const

URL traversal

The tree is traversed by calling getChild() with successive path components, on successive results. When getChild() returns null, or there are no more components, the last child responds to the request.

The default behavior is generally correct, though wildcard nodes will want to implement validate().

virtual LLHTTPNodegetChild (const std::string &name, LLSD &context) const
virtual bool handles (const LLSD &remainder, LLSD &context) const
const LLHTTPNodetraverse (const std::string &path, LLSD &context) const
virtual bool validate (const std::string &name, LLSD &context) const

Responses

Most subclasses override one or more of these methods to provide the service. By default, the rest of the LLHTTPNode architecture will handle requests, create the needed LLIOPump, parse the input to LLSD, and format the LLSD result to the output.

The default implementation of each of these is to call response->methodNotAllowed(); The "simple" versions can be overridden instead in those cases where the service can return an immediately computed response.





typedef LLPointer< Response > ResponsePtr
virtual void del (ResponsePtr, const LLSD &context) const
virtual LLSD del (const LLSD &context) const
virtual void get (ResponsePtr, const LLSD &context) const
virtual LLSD get () const
virtual void options (ResponsePtr, const LLSD &context) const
virtual void post (ResponsePtr, const LLSD &context, const LLSD &input) const
virtual LLSD post (const LLSD &input) const
virtual void put (ResponsePtr, const LLSD &context, const LLSD &input) const
virtual LLSD put (const LLSD &input) const

Detailed Description

Base class which handles url traversal, response routing and support for standard LLSD services.

These classes represent the HTTP framework: The URL tree, and the LLSD REST interface that such nodes implement.

To implement a service, in most cases, subclass LLHTTPNode, implement get() or post(), and create a global instance of LLHTTPRegistration<>. This can all be done in a .cpp file, with no publically declared parts.

To implement a server see lliohttpserver.h

See also:
LLHTTPWireServer

Users of the HTTP responder will typically derive a class from this one, implement the get(), put() and/or post() methods, and then use LLHTTPRegistration to insert it into the URL tree.

The default implementation handles servicing the request and creating the pipe fittings needed to read the headers, manage them, convert to and from LLSD, etc.


Member Function Documentation

LLHTTPNode * LLHTTPNode::getChild ( const std::string &  name,
LLSD context 
) const [virtual]

returns a child node, if any, at the given name default looks at children and wildcard child (see below)

const LLChainIOFactory * LLHTTPNode::getProtocolHandler (  )  const [virtual]

Return a factory object for handling wire protocols. The base class returns NULL, as it doesn't know about wire protocols at all. This is okay for most nodes as LLIOHTTPServer is smart enough to use a default wire protocol for HTTP for such nodes. Specialized subclasses that handle things like XML-RPC will want to implement this. (See LLXMLSDRPCServerFactory.)

bool LLHTTPNode::handles ( const LLSD remainder,
LLSD context 
) const [virtual]

return true if this node can service the remaining components; default returns true if there are no remaining components

const LLHTTPNode * LLHTTPNode::traverse ( const std::string &  path,
LLSD context 
) const

find a node, if any, that can service this path set up context["request"] information

Here is the call graph for this function:

bool LLHTTPNode::validate ( const std::string &  name,
LLSD context 
) const [virtual]

called only on wildcard nodes, to check if they will handle the name; default is false; overrides will want to check name, and return true if the name will construct to a valid url. For convenience, the getChild() method above will automatically insert the name in context["request"]["wildcard"][key] if this method returns true. For example, the node "agent/<agent_id>/detail" will set context["request"]["wildcard"]["agent_id"] eqaul to the value found during traversal.


The documentation for this class was generated from the following files:
  • /home/doug/src/oss/slitechat/trunk/LLChatLib/llmessage/llhttpnode.h
  • /home/doug/src/oss/slitechat/trunk/LLChatLib/llmessage/llhttpnode.cpp
Generated on Thu Sep 23 17:18:41 2010 for LLChatLib by  doxygen 1.6.3