From: Dean M. B. <mik...@gm...> - 2011-01-18 05:07:42
|
Hi Max, Sorry for the late response this time, I've been asleep for a bit and taking a break earlier today. Please see thoughts below. On Tue, Jan 18, 2011 at 12:11 AM, Max Malmgren <ma...@kt...> wrote: > Hey everybody. > > I have a problem using the asynchronous server version of the cpp-netlib. As > soon as I make a request a bad_cast exception is cast on the thread that ran > .run(). > > I am making a request to > "http://localhost:11200/proxy/?url=http://www.google.se", but all other > requests seem to fail aswell. > > This is working fine for the synchronous version of the server. I am making > this request from firefox. Also, I am using v0.8 of the library. > Can you please send the exact request that the browser sends over the line? Can you please use something like FireBug to catch the raw request (with method, headers, and body) that it sends to the server? > Any ideas? Checking the documentation for using the async-server, it seems > to be pretty identical to what I am doing. > > //asyncproxy.cpp > #include <string> > #include "asyncproxy.h" > > namespace proxy { > void ASyncProxy::startProxy(std::string url, std::string port) > { > boost::network::utils::thread_pool thread_pool(2); > http_server server(url, port, *this, thread_pool); > server.run(); > } > ASyncProxy::ASyncProxy(void (*callback)(std::string)) > { > this->callback = callback; > } > void ASyncProxy::operator()(http_server::request const & req, > http_server::connection_ptr connection) > { > connection->set_status(http_server::connection::ok); This is it? Unfortunately you'd need to write out headers and data to the connection too for anything to actually be sent through the connection. Please check the test in libs/network/test/http_async_server.cpp to see what an asynchronous handler should look like. HTH -- Dean Michael Berris about.me/deanberris |