Go to the documentation of this file.
6 #include <boost/bind.hpp>
7 #include <boost/enable_shared_from_this.hpp>
8 #include <boost/noncopyable.hpp>
9 #include <boost/regex.hpp>
10 #include <boost/shared_ptr.hpp>
14 using ssize_t = SSIZE_T;
22 : default_handler_(default_handler)
52 handlers_.push_back(std::make_pair(predicate, handler));
56 const HttpRequest& request, boost::shared_ptr<HttpConnection> connection,
57 const char* begin,
const char* end)
61 if (handler.first(request))
63 if (handler.second(request, connection, begin, end))
72 typedef boost::weak_ptr<BodyCollectingConnection>
75 :
public boost::enable_shared_from_this<BodyCollectingConnection>,
76 private boost::noncopyable
81 boost::shared_ptr<HttpConnection> connection)
85 std::string length_str =
89 length_ = boost::lexical_cast<ssize_t>(length_str);
91 catch (
const boost::bad_lexical_cast&)
98 const char* begin,
const char* end)
100 _this->handle_read(begin, end);
110 std::string chunk(begin, end - begin);
122 shared_from_this(), _1, _2));
141 const HttpRequest& request, boost::shared_ptr<HttpConnection> connection,
142 const char* begin,
const char* end)
146 collecting_connection->handle_read(begin, end);
HttpRequestBodyCollector(Handler handler)
const HttpRequest request_
bool operator()(const HttpRequest &request, boost::shared_ptr< HttpConnection > connection, const char *begin, const char *end)
boost::function< bool(const HttpRequest &, boost::shared_ptr< HttpConnection >, const char *begin, const char *end)> HttpServerRequestHandler
boost::weak_ptr< BodyCollectingConnection > BodyCollectingConnectionWeakPtr
boost::function< bool(const HttpRequest &)> HandlerPredicate
void addHandler(HandlerPredicate predicate, HttpServerRequestHandler handler)
static void static_handle_read(BodyCollectingConnectionPtr _this, const char *begin, const char *end)
std::stringstream body_stream_
HttpRequestHandlerGroup(HttpServerRequestHandler default_handler)
void handle_read(const char *begin, const char *end)
HttpRequestBodyCollector::Handler handler_
BodyCollectingConnection(HttpRequestBodyCollector::Handler handler, const HttpRequest &request, boost::shared_ptr< HttpConnection > connection)
std::string get_header_value_or_default(const std::string &name, const std::string &default_value) const
std::vector< std::pair< HandlerPredicate, HttpServerRequestHandler > > handlers_
HttpServerRequestHandler default_handler_
PathMatcher(const std::string &path_regex_string)
static ReplyBuilder builder(status_type status)
void write(HttpConnectionPtr connection)
void addHandlerForPath(const std::string &path_regex, HttpServerRequestHandler handler)
boost::shared_ptr< HttpConnection > connection_
boost::function< void(const HttpRequest &, boost::shared_ptr< HttpConnection >, const std::string &body)> Handler
bool operator()(const HttpRequest &request)
bool operator()(const HttpRequest &request, boost::shared_ptr< HttpConnection > connection, const char *begin, const char *end)
const boost::regex path_regex_
boost::shared_ptr< BodyCollectingConnection > BodyCollectingConnectionPtr
async_web_server_cpp
Author(s): Mitchell Wills
, Russel Toris
autogenerated on Tue Mar 1 2022 23:49:06