Exemplo n.º 1
0
void ProxyReply::handleStatusRead(const Wt::AsioWrapper::error_code &ec)
{
  if (!ec) {
    std::istream response_stream(&responseBuf_);
    std::string http_version;
    response_stream >> http_version;
    int status_code;
    response_stream >> status_code;
    setStatus((Reply::status_type) status_code);
    std::string status_message;
    std::getline(response_stream, status_message);
    if (!response_stream || http_version.substr(0, 5) != "HTTP/") {
      LOG_ERROR("got malformed response!");
      if (!sendReload())
	error(internal_server_error);
      return;
    }

    asio::async_read_until
      (*socket_, responseBuf_, "\r\n\r\n",
       connection()->strand().wrap
       (std::bind(&ProxyReply::handleHeadersRead,
		  std::static_pointer_cast<ProxyReply>(shared_from_this()),
		  std::placeholders::_1)));
  } else {
Exemplo n.º 2
0
void ProxyReply::handleDataWritten(const boost::system::error_code &ec,
	std::size_t transferred)
{
  if (!ec) {
    if (state_ == Request::Partial) {
      requestBuf_.consume(transferred);
      receive();
    } else {
      asio::async_read_until(*socket_, responseBuf_, "\r\n",
	  boost::bind(&ProxyReply::handleStatusRead,
	    boost::dynamic_pointer_cast<ProxyReply>(shared_from_this()),
	    asio::placeholders::error));
    }
  } else {
    LOG_ERROR("error sending data to child: " << ec.message());
    if (!sendReload())
      error(service_unavailable);
  }
}
Exemplo n.º 3
0
void ProxyReply::handleDataWritten(const Wt::AsioWrapper::error_code &ec,
				   std::size_t transferred)
{
  if (!ec) {
    if (state_ == Request::Partial) {
      requestBuf_.consume(transferred);
      LOG_DEBUG(this << ": receive() upstream");
      receive();
    } else {
      asio::async_read_until
	(*socket_, responseBuf_, "\r\n",
	 connection()->strand().wrap
	 (std::bind
	  (&ProxyReply::handleStatusRead,
	   std::static_pointer_cast<ProxyReply>(shared_from_this()),
	   std::placeholders::_1)));
    }
  } else {
    LOG_ERROR("error sending data to child: " << ec.message());
    if (!sendReload())
      error(service_unavailable);
  }
}