Добрый день!
Нужно сделать асинхронный http сервер. Есть хандлер:
namespace http = boost::network::http;
namespace utils = boost::network::utils;
class AsyncHandler;
class SyncHandler;
typedef http::async_server<AsyncHandler> AsyncServer;
typedef http::server<SyncHandler> SyncServer;
//...
class AsyncHandler
{
public:
typedef AsyncServer Server;
typedef Server::request Request;
typedef Server::response Response;
typedef Server::connection Connection;
typedef Server::connection_ptr ConnectionPtr;
typedef Server::response_header ResponseHeader;
typedef Server::string_type StringType;
public:
AsyncHandler()
{}
void operator()(const Request& request,
ConnectionPtr connection);
};
//...
void AsyncHandler::operator()(const Request& request, ConnectionPtr connection)
{
static Server::response_header error_headers[] =
{
{ "Connection", "close" }
};
std::string dest = request.destination;
long port = request.source_port;
std::string src = request.source;
std::string body = request.body;
if (request.method == "HEAD" || request.method == "GET")
{
// ...
}
else
if (request.method == "POST")
{
// ...
}
else
{
connection->set_status(Server::connection::not_supported);
connection->set_headers(boost::make_iterator_range(std::begin(error_headers), std::end(error_headers) ) );
connection->write("Method not supported.");
}
}
В документации есть такая картинка:
Нужно получить:
authority, path, query и fragment
Кажется должно быть все просто, но примеров очень мало.