⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _h_t_t_p_server_8hpp-source.html

📁 用c++编写http server的源码库,对socket等网络处理的代码可迅速转为己用.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>libpion: /Users/mdickey/code/libpion-export/include/libpion/HTTPServer.hpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><div class="tabs">  <ul>    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>    <li><a href="namespaces.html"><span>Namespaces</span></a></li>    <li><a href="annotated.html"><span>Classes</span></a></li>    <li class="current"><a href="files.html"><span>Files</span></a></li>  </ul></div><h1>/Users/mdickey/code/libpion-export/include/libpion/HTTPServer.hpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -----------------------------------------------------------------</span><a name="l00002"></a>00002 <span class="comment">// libpion: a C++ framework for building lightweight HTTP interfaces</span><a name="l00003"></a>00003 <span class="comment">// -----------------------------------------------------------------</span><a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007 Atomic Labs, Inc.  (http://www.atomiclabs.com)</span><a name="l00005"></a>00005 <span class="comment">//</span><a name="l00006"></a>00006 <span class="comment">// Distributed under the Boost Software License, Version 1.0.</span><a name="l00007"></a>00007 <span class="comment">// See accompanying file COPYING or copy at http://www.boost.org/LICENSE_1_0.txt</span><a name="l00008"></a>00008 <span class="comment">//</span><a name="l00009"></a>00009 <a name="l00010"></a>00010 <span class="preprocessor">#ifndef __PION_HTTPSERVER_HEADER__</span><a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor">#define __PION_HTTPSERVER_HEADER__</span><a name="l00012"></a>00012 <span class="preprocessor"></span><a name="l00013"></a>00013 <span class="preprocessor">#include &lt;libpion/PionConfig.hpp&gt;</span><a name="l00014"></a>00014 <span class="preprocessor">#include &lt;libpion/PionException.hpp&gt;</span><a name="l00015"></a>00015 <span class="preprocessor">#include &lt;libpion/PionPlugin.hpp&gt;</span><a name="l00016"></a>00016 <span class="preprocessor">#include &lt;libpion/TCPServer.hpp&gt;</span><a name="l00017"></a>00017 <span class="preprocessor">#include &lt;libpion/TCPConnection.hpp&gt;</span><a name="l00018"></a>00018 <span class="preprocessor">#include &lt;libpion/HTTPModule.hpp&gt;</span><a name="l00019"></a>00019 <span class="preprocessor">#include &lt;boost/shared_ptr.hpp&gt;</span><a name="l00020"></a>00020 <span class="preprocessor">#include &lt;boost/thread/mutex.hpp&gt;</span><a name="l00021"></a>00021 <span class="preprocessor">#include &lt;string&gt;</span><a name="l00022"></a>00022 <span class="preprocessor">#include &lt;map&gt;</span><a name="l00023"></a>00023 <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="keyword">namespace </span>pion {    <span class="comment">// begin namespace pion</span><a name="l00026"></a>00026 <a name="l00030"></a><a class="code" href="classpion_1_1_h_t_t_p_server.html">00030</a> <span class="keyword">class </span><a class="code" href="classpion_1_1_h_t_t_p_server.html">HTTPServer</a> :<a name="l00031"></a>00031     <span class="keyword">public</span> <a class="code" href="classpion_1_1_t_c_p_server.html">TCPServer</a><a name="l00032"></a>00032 {<a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="keyword">public</span>:<a name="l00035"></a>00035 <a name="l00037"></a><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_module_not_found_exception.html">00037</a>     <span class="keyword">class </span><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_module_not_found_exception.html" title="exception thrown if a module cannot be found">ModuleNotFoundException</a> : <span class="keyword">public</span> <a class="code" href="classpion_1_1_pion_exception.html">PionException</a> {<a name="l00038"></a>00038     <span class="keyword">public</span>:<a name="l00039"></a><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_module_not_found_exception.html#257a5f3995736b5f8f35e9c734d0a5a1">00039</a>         <a class="code" href="classpion_1_1_h_t_t_p_server_1_1_module_not_found_exception.html#257a5f3995736b5f8f35e9c734d0a5a1">ModuleNotFoundException</a>(<span class="keyword">const</span> std::string&amp; resource)<a name="l00040"></a>00040             : <a class="code" href="classpion_1_1_pion_exception.html">PionException</a>(<span class="stringliteral">"No modules are identified by the resource: "</span>, resource) {}<a name="l00041"></a>00041     };<a name="l00042"></a>00042 <a name="l00044"></a><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_not_found_exception.html">00044</a>     <span class="keyword">class </span><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_not_found_exception.html" title="exception thrown if the plug-in configuration file cannot be found">ConfigNotFoundException</a> : <span class="keyword">public</span> <a class="code" href="classpion_1_1_pion_exception.html">PionException</a> {<a name="l00045"></a>00045     <span class="keyword">public</span>:<a name="l00046"></a><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_not_found_exception.html#4bc09e5835108224574c586fd2878dd8">00046</a>         <a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_not_found_exception.html#4bc09e5835108224574c586fd2878dd8">ConfigNotFoundException</a>(<span class="keyword">const</span> std::string&amp; file)<a name="l00047"></a>00047             : <a class="code" href="classpion_1_1_pion_exception.html">PionException</a>(<span class="stringliteral">"Module configuration file not found: "</span>, file) {}<a name="l00048"></a>00048     };<a name="l00049"></a>00049     <a name="l00051"></a><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_parsing_exception.html">00051</a>     <span class="keyword">class </span><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_parsing_exception.html" title="exception thrown if the plug-in file cannot be opened">ConfigParsingException</a> : <span class="keyword">public</span> <a class="code" href="classpion_1_1_pion_exception.html">PionException</a> {<a name="l00052"></a>00052     <span class="keyword">public</span>:<a name="l00053"></a><a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_parsing_exception.html#9c836b8753ec1bcb3f3dca30ea7b139b">00053</a>         <a class="code" href="classpion_1_1_h_t_t_p_server_1_1_config_parsing_exception.html#9c836b8753ec1bcb3f3dca30ea7b139b">ConfigParsingException</a>(<span class="keyword">const</span> std::string&amp; file)<a name="l00054"></a>00054             : <a class="code" href="classpion_1_1_pion_exception.html">PionException</a>(<span class="stringliteral">"Unable to parse configuration file: "</span>, file) {}<a name="l00055"></a>00055     };<a name="l00056"></a>00056 <a name="l00058"></a>00058     <span class="keyword">typedef</span> boost::function2&lt;void, <a class="code" href="namespacepion.html#3c0f3fad0f449ebd309eaf4872f2b222" title="data type for a HTTP request pointer">HTTPRequestPtr</a>&amp;,<a name="l00059"></a><a class="code" href="classpion_1_1_h_t_t_p_server.html#2be32ffd74ea6e1a01ad7faaf9ccebc3">00059</a>         <a class="code" href="namespacepion.html#1858b89656b28c6498ad9efd6b7e9d41" title="data type for a TCPConnection pointer">TCPConnectionPtr</a>&amp;&gt;  <a class="code" href="classpion_1_1_h_t_t_p_server.html#2be32ffd74ea6e1a01ad7faaf9ccebc3" title="handler for requests that result in "400 Bad Request"">BadRequestHandler</a>;<a name="l00060"></a>00060 <a name="l00062"></a>00062     <span class="keyword">typedef</span> boost::function2&lt;void, <a class="code" href="namespacepion.html#3c0f3fad0f449ebd309eaf4872f2b222" title="data type for a HTTP request pointer">HTTPRequestPtr</a>&amp;,<a name="l00063"></a><a class="code" href="classpion_1_1_h_t_t_p_server.html#67bd834e0b81b718ee551820478c7864">00063</a>          <a class="code" href="namespacepion.html#1858b89656b28c6498ad9efd6b7e9d41" title="data type for a TCPConnection pointer">TCPConnectionPtr</a>&amp;&gt; <a class="code" href="classpion_1_1_h_t_t_p_server.html#67bd834e0b81b718ee551820478c7864" title="handler for requests that result in "404 Not Found"">NotFoundHandler</a>;<a name="l00064"></a>00064 <a name="l00066"></a>00066     <span class="keyword">typedef</span> boost::function3&lt;void, <a class="code" href="namespacepion.html#3c0f3fad0f449ebd309eaf4872f2b222" title="data type for a HTTP request pointer">HTTPRequestPtr</a>&amp;, <a class="code" href="namespacepion.html#1858b89656b28c6498ad9efd6b7e9d41" title="data type for a TCPConnection pointer">TCPConnectionPtr</a>&amp;,<a name="l00067"></a><a class="code" href="classpion_1_1_h_t_t_p_server.html#e66c8d13458b5d597e4ab5f8a80d18db">00067</a>         <span class="keyword">const</span> std::string&amp;&gt; <a class="code" href="classpion_1_1_h_t_t_p_server.html#e66c8d13458b5d597e4ab5f8a80d18db" title="handler for requests that result in "500 Server Error"">ServerErrorHandler</a>;<a name="l00068"></a>00068     <a name="l00069"></a>00069     <a name="l00075"></a><a class="code" href="classpion_1_1_h_t_t_p_server.html#ad3704c715ed243c9133eceff99fc851">00075</a>     <span class="keyword">static</span> <span class="keyword">inline</span> boost::shared_ptr&lt;HTTPServer&gt; <a class="code" href="classpion_1_1_h_t_t_p_server.html#ad3704c715ed243c9133eceff99fc851">create</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tcp_port)<a name="l00076"></a>00076     {<a name="l00077"></a>00077         <span class="keywordflow">return</span> boost::shared_ptr&lt;HTTPServer&gt;(<span class="keyword">new</span> <a class="code" href="classpion_1_1_h_t_t_p_server.html#cc15aa773af3c82620cd3895ca9a9058">HTTPServer</a>(tcp_port));<a name="l00078"></a>00078     }<a name="l00079"></a>00079 <a name="l00081"></a><a class="code" href="classpion_1_1_h_t_t_p_server.html#b323c97fe17a123dd91dbecf2ec7763f">00081</a>     <span class="keyword">virtual</span> <a class="code" href="classpion_1_1_h_t_t_p_server.html#b323c97fe17a123dd91dbecf2ec7763f" title="default destructor">~HTTPServer</a>() {}<a name="l00082"></a>00082     <a name="l00089"></a>00089     <span class="keywordtype">void</span> <a class="code" href="classpion_1_1_h_t_t_p_server.html#bb4bab0c980efa48976f3982c85db100">addModule</a>(<span class="keyword">const</span> std::string&amp; resource, <a class="code" href="classpion_1_1_h_t_t_p_module.html">HTTPModule</a> *module_ptr);<a name="l00090"></a>00090     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -