#include <llhttpnode.h>
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 LLSD | get () const |
virtual LLSD | put (const LLSD &input) const |
virtual LLSD | post (const LLSD &input) const |
virtual LLSD | del (const LLSD &context) const |
virtual void | get (ResponsePtr, const LLSD &context) const |
virtual void | put (ResponsePtr, const LLSD &context, const LLSD &input) const |
virtual void | post (ResponsePtr, const LLSD &context, const LLSD &input) const |
virtual void | del (ResponsePtr, const LLSD &context) const |
Public Member Functions | |
LLHTTPNode () | |
virtual | ~LLHTTPNode () |
virtual const LLChainIOFactory * | getProtocolHandler () 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 LLHTTPNode * | getChild (const std::string &name, LLSD &context) const |
virtual bool | handles (const LLSD &remainder, LLSD &context) const |
virtual bool | validate (const std::string &name, LLSD &context) const |
const LLHTTPNode * | traverse (const std::string &path, LLSD &context) 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 LLHTTPNode * | rootNode () const |
const LLHTTPNode * | findNode (const std::string &name) const |
virtual void | describe (Description &) const |
Private Attributes | |
Impl & | impl |
Classes | |
class | Description |
class | Impl |
class | Response |
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
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.
Definition at line 66 of file llhttpnode.h.
typedef LLPointer<Response> LLHTTPNode::ResponsePtr |
Definition at line 106 of file llhttpnode.h.
LLHTTPNode::LLHTTPNode | ( | ) |
Definition at line 76 of file llhttpnode.cpp.
Referenced by addNode().
LLHTTPNode::~LLHTTPNode | ( | ) | [virtual] |
Definition at line 82 of file llhttpnode.cpp.
References impl, LLHTTPNode::Impl::mNamedChildren, and LLHTTPNode::Impl::mWildcardChild.
LLSD LLHTTPNode::get | ( | ) | const [virtual] |
Reimplemented in LLHTTPConfigService, LLHTTPConfigRuntimeService, LLHTTPHelloService, and tut::LLSDStorageNode.
Definition at line 100 of file llhttpnode.cpp.
Referenced by tut::HTTPNodeTestData::get().
Reimplemented in tut::LLSDStorageNode.
Definition at line 106 of file llhttpnode.cpp.
Referenced by put().
Reimplemented in LLHTTPEchoService.
Definition at line 112 of file llhttpnode.cpp.
Referenced by LLMessageSystem::dispatch(), tut::HTTPNodeTestData::post(), and post().
Definition at line 172 of file llhttpnode.cpp.
Referenced by del().
void LLHTTPNode::get | ( | LLHTTPNode::ResponsePtr | response, | |
const LLSD & | context | |||
) | const [virtual] |
Reimplemented in LLHTTPConfigRuntimeSingleService, LLHTTPConfigPriorityService< PRIORITY >, LLHTTPLiveConfigService, LLHTTPLiveConfigSingleService, LLAPIService, tut::ErrorNode, tut::TimeOutNode, tut::IntegerNode, and tut::SquareNode.
Definition at line 119 of file llhttpnode.cpp.
void LLHTTPNode::put | ( | LLHTTPNode::ResponsePtr | response, | |
const LLSD & | context, | |||
const LLSD & | input | |||
) | const [virtual] |
Reimplemented in LLHTTPConfigRuntimeSingleService.
Definition at line 132 of file llhttpnode.cpp.
References put().
void LLHTTPNode::post | ( | LLHTTPNode::ResponsePtr | response, | |
const LLSD & | context, | |||
const LLSD & | input | |||
) | const [virtual] |
Reimplemented in LLHTTPConfigRuntimeService, LLTrustedMessageService, LLMessageHandlerBridge, LLAgentDropGroupViewerNode, LLAgentGroupDataUpdateViewerNode, LLViewerChatterBoxSessionStartReply, LLViewerChatterBoxSessionEventReply, LLViewerForceCloseChatterBoxSession, LLViewerChatterBoxSessionAgentListUpdates, LLViewerChatterBoxSessionUpdate, LLViewerChatterBoxInvitation, CoarseLocationUpdate, LLViewerParcelVoiceInfo, LLViewerRequiredVoiceVersion, LLEstablishAgentCommunication, tut::ErrorNode, and tut::HTTPServiceTestData::DelayedEcho.
Definition at line 145 of file llhttpnode.cpp.
References post().
void LLHTTPNode::del | ( | LLHTTPNode::ResponsePtr | response, | |
const LLSD & | context | |||
) | const [virtual] |
Reimplemented in LLHTTPConfigRuntimeSingleService.
Definition at line 158 of file llhttpnode.cpp.
References del().
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)
Definition at line 179 of file llhttpnode.cpp.
References CONTEXT_REQUEST(), CONTEXT_WILDCARD(), get_ptr_in_map(), impl, LLHTTPNode::Impl::mNamedChildren, LLHTTPNode::Impl::mWildcardChild, LLHTTPNode::Impl::mWildcardKey, NULL, and validate().
Referenced by traverse().
return true if this node can service the remaining components; default returns true if there are no remaining components
Reimplemented in LLAPIService, and tut::AlphaNode.
Definition at line 199 of file llhttpnode.cpp.
References LLSD::size().
Referenced by traverse().
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.
Reimplemented in LLHTTPConfigRuntimeSingleService, LLHTTPLiveConfigSingleService, LLTrustedMessageService, LLMessageHandlerBridge, and tut::IntegerNode.
Definition at line 205 of file llhttpnode.cpp.
Referenced by getChild().
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
Definition at line 210 of file llhttpnode.cpp.
References LLSD::append(), CONTEXT_REQUEST(), getChild(), handles(), lldebugs, llendl, and NULL.
Referenced by LLMessageSystem::dispatch(), tut::HTTPNodeTestData::ensureRootTraversal(), tut::HTTPNodeTestData::get(), tut::HTTPNodeTestData::post(), and LLHTTPResponder::process_impl().
void LLHTTPNode::addNode | ( | const std::string & | path, | |
LLHTTPNode * | nodeToAdd | |||
) | [virtual] |
Definition at line 244 of file llhttpnode.cpp.
References LLHTTPNode::Impl::findNamedChild(), impl, llendl, LLHTTPNode(), llwarns, LLHTTPNode::Impl::mNamedChildren, LLHTTPNode::Impl::mParentNode, LLHTTPNode::Impl::mWildcardChild, LLHTTPNode::Impl::mWildcardKey, and LLHTTPNode::Impl::mWildcardName.
Referenced by LLHTTPRegistrar::buildAllServices(), and tut::HTTPServiceTestData::HTTPServiceTestData().
LLSD LLHTTPNode::allNodePaths | ( | ) | const |
Returns an arrary of node paths at and under this node.
Definition at line 324 of file llhttpnode.cpp.
References append_node_paths(), i, impl, LLHTTPNode::Impl::mNamedChildren, LLHTTPNode::Impl::mWildcardChild, and LLHTTPNode::Impl::mWildcardName.
Referenced by append_node_paths().
const LLHTTPNode * LLHTTPNode::rootNode | ( | ) | const |
const LLHTTPNode * LLHTTPNode::findNode | ( | const std::string & | name | ) | const |
Definition at line 360 of file llhttpnode.cpp.
References LLHTTPNode::Impl::findNamedChild(), and impl.
Referenced by LLAPIService::followRemainder().
void LLHTTPNode::describe | ( | Description & | desc | ) | const [virtual] |
Reimplemented in LLHTTPConfigService, LLHTTPConfigRuntimeService, LLHTTPConfigRuntimeSingleService, LLHTTPConfigPriorityService< PRIORITY >, LLHTTPLiveConfigService, LLHTTPLiveConfigSingleService, LLHTTPHelloService, LLHTTPEchoService, LLAPIService, LLViewerChatterBoxSessionStartReply, LLViewerChatterBoxSessionEventReply, and LLEstablishAgentCommunication.
Definition at line 389 of file llhttpnode.cpp.
References LLHTTPNode::Description::shortInfo().
Referenced by LLAPIService::get().
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.)
Reimplemented in LLHTTPNodeForFactory< Factory >, LLHTTPNodeForFactory< LLXMLRPCServerFactory< Server > >, LLHTTPNodeForFactory< LLChainIOFactoryForPipe< Pipe > >, and LLHTTPNodeForFactory< LLSDRPCServerFactory< Server > >.
Definition at line 395 of file llhttpnode.cpp.
References NULL.
Referenced by LLHTTPResponder::process_impl().
Impl& LLHTTPNode::impl [private] |
Definition at line 221 of file llhttpnode.h.
Referenced by addNode(), allNodePaths(), findNode(), getChild(), rootNode(), and ~LLHTTPNode().