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.
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);
}
}
int main()
{
proxy::ASyncProxy prox(&writeQueue);
prox.startProxy("localhost", 11200);
}
//asyncproxy.h
#include <boost\network\protocol\http\server.hpp>
#include <boost\network\utils\thread_pool.hpp>
namespace proxy {
struct ASyncProxy {
typedef boost::network::http::async_server<ASyncProxy> http_server;
public:
void startProxy(std::string url, std::string port);
ASyncProxy(void (*callback)(std::string));
void operator()(http_server::request const & req,
http_server::connection_ptr connection);
private:
void (*callback)(std::string);
};
}
#endif
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Cpp-netlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel