From: Severin P. <pap...@gm...> - 2011-02-24 01:51:05
|
Hi, All Ubuntu 10.10 64bit, gcc-4.4 Build BOOST 1.46, and on top of it cpp-netlib 0.8.1. The only thing I did was to declare to use BOOST_FILESYSTEM version 2, got one issue: some tests didn't do good, but when I tried them manually, seems to work (well, except MIME parser). Now question: could I use the code to push files forth and back? Fielserver.cpp seems to be good point to start to get data back, but could I push it from client to server to store data? thank you Sever |
From: Dean M. B. <mik...@gm...> - 2011-02-24 04:53:09
|
Hi Sever, On Thu, Feb 24, 2011 at 9:50 AM, Severin Pappadeux <pap...@gm...> wrote: > Hi, All > Ubuntu 10.10 64bit, gcc-4.4 > Build BOOST 1.46, and on top of it cpp-netlib 0.8.1. > The only thing I did was to declare to use BOOST_FILESYSTEM version 2, got > one issue: > some tests didn't do good, but when I tried them manually, seems to work > (well, except MIME parser). Yeah, the MIME stuff is currently un-maintained but last I checked is practically functional. > Now question: > could I use the code to push files forth and back? Fielserver.cpp seems to > be good point to start to get data back, but could I push it > from client to server to store data? You can definitely use the HTTP client(s) in cpp-netlib to push data via PUT/POST -- you just have to craft the appropriate requests. At the moment the way to do it is terribly inefficient, and I hope to be able to address those issues soon. Having said that, the fileserver example can be extended to support PUT/POST, but it wouldn't be a simple example anymore if I do that. ;) > thank you Thanks for trying it out. In case you have any more questions please feel free to ask on the list again and we'll try to help you out as soon as we can. :D -- Dean Michael Berris about.me/deanberris |
From: Severin P. <pap...@gm...> - 2011-02-25 04:52:53
|
Hi again well,what would be nice to have is to print incoming requests on server side, both header and body. Something like it is done in one of the client examples. Would be nice to have it for general use - for debugging and verbose logging I've tried to copy printing body/header code from client to server (with appropriate changes), but it didn't compile. Any advices? regards Sever On Wed, Feb 23, 2011 at 11:52 PM, Dean Michael Berris < mik...@gm...> wrote: > Hi Sever, > > On Thu, Feb 24, 2011 at 9:50 AM, Severin Pappadeux <pap...@gm...> > wrote: > > Hi, All > > Ubuntu 10.10 64bit, gcc-4.4 > > Build BOOST 1.46, and on top of it cpp-netlib 0.8.1. > > The only thing I did was to declare to use BOOST_FILESYSTEM version 2, > got > > one issue: > > some tests didn't do good, but when I tried them manually, seems to work > > (well, except MIME parser). > > Yeah, the MIME stuff is currently un-maintained but last I checked is > practically functional. > > > Now question: > > could I use the code to push files forth and back? Fielserver.cpp seems > to > > be good point to start to get data back, but could I push it > > from client to server to store data? > > You can definitely use the HTTP client(s) in cpp-netlib to push data > via PUT/POST -- you just have to craft the appropriate requests. At > the moment the way to do it is terribly inefficient, and I hope to be > able to address those issues soon. > > Having said that, the fileserver example can be extended to support > PUT/POST, but it wouldn't be a simple example anymore if I do that. ;) > > > thank you > > Thanks for trying it out. In case you have any more questions please > feel free to ask on the list again and we'll try to help you out as > soon as we can. :D > > -- > Dean Michael Berris > about.me/deanberris > |
From: Dean M. B. <mik...@gm...> - 2011-02-25 06:28:32
|
Hi Sever, Next time, please don't top-post. See my response in-lined below: On Fri, Feb 25, 2011 at 12:52 PM, Severin Pappadeux <pap...@gm...> wrote: > > Hi again > well,what would be nice to have is to print incoming requests > on server side, both header and body. Something like it is done in > one of the client examples. Would be nice to have it for > general use - for debugging and verbose logging That should be easy to do. > I've tried to copy printing body/header code from client to server (with appropriate changes), > but it didn't compile. Any advices? Can you show us the code? I can't help you without seeing the code you have and the errors you're encountering. -- Dean Michael Berris about.me/deanberris |
From: Oleg M. <ole...@gm...> - 2011-02-25 07:27:31
Attachments:
signature.asc
|
On 25.02.2011 14:52, Severin Pappadeux wrote: > I've tried to copy printing body/header code from client to server (with > appropriate changes), > but it didn't compile. Any advices? We have issues with printing response body. Dean seems to be very busy to address this problem. Please take a look at that message and let me know if described workaround works for you. http://www.mail-archive.com/cpp...@li.../msg00689.html -- Best regards, Oleg Malashenko. |
From: Severin P. <pap...@gm...> - 2011-02-25 20:48:27
|
Hi, All below is echo server source code - Do Not Work. Could I extract headers from request? Looking from three miles down to design decision, made in cpp-netlib, it would be nice to have uniform methods, applicable to both *request* and*response. * There are, of course, some differences to be handled in a different way, but for both headers(request|response) shall return pointer/reference to headers, and preferable of the same type, body(request|response) shall return pointer/reference to headers, and preferable of the same type and so on and so forth. After all, they're very similar and both based upon basic_message building block sincerely Sever PS BOOST 1.46 gcc 4.4, Ubuntu 10.10 x64 ------------------------------------------------------------- cut here --------------------------------------------------------------------- // // "echo" server // simple test server, should just print source/body/headers of the request and copy into response // #include <boost/network/protocol/http/server.hpp> #include <boost/function_output_iterator.hpp> #include <string> #include <iostream> struct headerPrinter { std::ostream& _os; headerPrinter(std::ostream & os): _os(os) { } headerPrinter(const headerPrinter& hp): _os(hp._os) { } template <class Pair> void operator()(const Pair& p) { _os << p.first << ": " << p.second << std::endl; } }; struct theHandler { #pragma region Data std::ostream* _log; #pragma endregion #pragma region Ctor/Dtor theHandler(std::ostream* log = 0): _log(log) { } theHandler(const theHandler& thH): _log(thH._log) { } theHandler& operator=(const theHandler& thH) { if (this != &thH) { _log = thH._log; } return *this; } ~theHandler() { } #pragma endregion #pragma region Handler void operator() (const boost::network::http::server<theHandler>::request& request, boost::network::http::server<theHandler>::response& response) { using namespace boost::network; /* std::copy(headers_.begin(), headers_.end(), boost::make_function_output_iterator(header_printer(cout))); cout << endl; */ std::ostringstream data; // ok, printing source http::server<theHandler>::string_type src = source(request); data << "Hello, " << src << "!" << std::endl; // now printing body http::server<theHandler>::string_type body = body(request); data << body << std::endl; // try to print headers // DNW! // headers_range<http::server<theHandler>::request>::type _headers = request.headers(); // DNW either headers_range<http::server<theHandler>::request>::type _headers = headers(request); std::copy(_headers.begin(), _headers.end(), boost::make_function_output_iterator(headerPrinter(data))); data << std::endl; response = http::server<theHandler>::response::stock_reply(http::server<theHandler>::response::ok, data.str()); } #pragma endregion #pragma region Logger void log(...) { if (_log) { (*_log) << "LOG: " << std::endl; } } #pragma endregion }; int main(int argc, char * argv[]) { using namespace boost::network; if (argc != 3) { std::cerr << "Usage: " << argv[0] << " address" << " port" << std::endl; return EXIT_FAILURE; } try { // Creates the request handler theHandler handler; // Creates the server http::server<theHandler> server_(argv[1], argv[2], handler); // Runs the server server_.run(); } catch (std::exception &e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; } |
From: Dean M. B. <mik...@gm...> - 2011-03-16 01:28:01
|
Hmmm... I thought I responded to this email. Anyway, please see details below: On Sat, Feb 26, 2011 at 4:48 AM, Severin Pappadeux <pap...@gm...> wrote: > Hi, All > below is echo server source code - Do Not Work. Could I extract headers from > request? >From the server handler, you can use the `request.headers` member -- that's a vector of http::request_header<Tag> types, which have a `name` and `value` member in turn. > Looking from three miles down to design decision, made in cpp-netlib, > it would be nice to have uniform methods, applicable to both request and > response. > There are, of course, some differences to be handled in a different way, but > for both > headers(request|response) shall return pointer/reference to headers, and > preferable of the same type, > body(request|response) shall return pointer/reference to headers, and > preferable of the same type > and so on and so forth. After all, they're very similar and both based upon > basic_message building block That's already done in 0.9. HTH -- Dean Michael Berris http://about.me/deanberris |