cpp-netlib HTTP サーバー側のヘッダーに関するこの未回答の質問に似た (ただしより具体的な)質問。
これは、モードが3.5 または4.9 のcpp-netlib 0.11.1
Linux/Debian/Sid/x86-64 で使用する場合です。clang++
g++
-std=c++11
ところで、 cpp-netlib googlegroupでいくつかの例も尋ねました...
#include <fstream>
#include <iostream>
#include <boost/network/protocol/http/server.hpp>
#define DEBUG_OUT(Out) do {std::cout << __FILE__ << ":" << __LINE__ \
<< ' ' << Out << std::endl;} while(0)
namespace netlib_http = boost::network::http;
struct Yaca_web;
typedef netlib_http::server<Yaca_web> Yaca_server;
struct Yaca_web {
void operator() (Yaca_server::request const& request,
Yaca_server::response &response)
{
DEBUG_OUT("web request source="
<< std::string(source(request))
//<< " uri=" << std::string(uri(request)) ///@@@@@
);
};
void log(const std::string&s) { DEBUG_OUT("log s=" << s); };
}; // end Yaca_web
void ya_web_service(int port) {
DEBUG_OUT("ya_web_service start port=" << port);
Yaca_web webhandler;
Yaca_server::options weboptions {webhandler};
weboptions.address("localhost");
weboptions.port(std::to_string(port));
weboptions.reuse_address(true);
Yaca_server webserver {weboptions};
DEBUG_OUT("ya_web_service before running server");
webserver.run();
DEBUG_OUT("ya_web_service end port=" << port);
}
上記のコードは、行のコメントを外すとコンパイルされませんが、盲目的な推測として///@@@@@
使用しています:uri(request)
In file included from ywebx.cc:4:
In file included from /usr/include/boost/network/protocol/http/server.hpp:13:
In file included from /usr/include/boost/network/protocol/http/request.hpp:18:
/usr/include/boost/network/protocol/http/message/wrappers/uri.hpp:25:44: error:
no member named 'uri' in
'boost::network::http::basic_request<tags::http_server>'
operator string_type() { return message_.uri().raw(); }
~~~~~~~~ ^
ywebx.cc:18:34: note: in instantiation of member function
'boost::network::http::impl::uri_wrapper<boost::network::http::tags::http_server>::operator
basic_string' requested here
<< " uri=" << std::string(uri(request))
^
./yacax.h:49:18: note: expanded from macro 'DEBUG_OUT'
<< ' ' << Out << std::endl;} while(0)
^
詳細情報を取得する方法を知っている人はいますか? 特に、メソッド、パス、または URI、および一般的なMIME タイプのHTTPPOST
要求の場合、Web フォーム引数の辞書 (可能な場合) はありますか?application/x-www-form-urlencoded
cpp-netlib
Web フォーム用の HTTP サービスの簡単な例を見つけることができませんでした( libonioncpp-netlib
の C++11 に似たもの) 。examples/post/