Skip to content

Commit

Permalink
Rollback.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelKatz authored and vinniefalco committed May 3, 2013
1 parent b4b4f5c commit 405ccbc
Showing 1 changed file with 13 additions and 57 deletions.
70 changes: 13 additions & 57 deletions src/roles/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,6 @@

namespace websocketpp {

typedef boost::asio::buffers_iterator<boost::asio::streambuf::const_buffers_type> bufIterator;

static std::pair<bufIterator, bool> match_header(bufIterator begin, bufIterator end)
{
// Do we have a complete HTTP request
const std::string header_match = "\r\n\r\n";
bufIterator it = std::search(begin, end, header_match.begin(), header_match.end());
if (it != end)
return std::make_pair(it, true);

// If we don't have a flash policy request, we're done
const std::string flash_match = "<policy-file-request/>";
it = std::search(begin, end, flash_match.begin(), flash_match.end());
if (it == end)
return std::make_pair(end, false);

// If we have a line ending before the flash policy request, treat as http
const std::string eol_match = "\r\n";
bufIterator it2 = std::search(begin, end, eol_match.begin(), eol_match.end());
if ((it2 != end) || (it < it2))
return std::make_pair(end, false);

// Treat as flash policy request
return std::make_pair(it, true);
}

// Forward declarations
template <typename T> struct endpoint_traits;

Expand Down Expand Up @@ -539,36 +513,18 @@ void server<endpoint>::connection<connection_type>::async_init() {
// TODO: make this value configurable
m_connection.register_timeout(5000,fail::status::TIMEOUT_WS,
"Timeout on WebSocket handshake");

if (m_connection.isSecure())
{
boost::asio::async_read_until(
m_connection.SSLSocket(),
m_connection.buffer(),
// match_header,
"\r\n\r\n",
m_connection.get_strand().wrap(boost::bind(
&type::handle_read_request,
m_connection.shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
))
);
}
else
{
boost::asio::async_read_until(
m_connection.PlainSocket(),
m_connection.buffer(),
match_header,
m_connection.get_strand().wrap(boost::bind(
&type::handle_read_request,
m_connection.shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
))
);
}

boost::asio::async_read_until(
m_connection.get_socket(),
m_connection.buffer(),
"\r\n\r\n",
m_connection.get_strand().wrap(boost::bind(
&type::handle_read_request,
m_connection.shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
))
);
}

/// processes the response from an async read for an HTTP header
Expand Down Expand Up @@ -840,7 +796,7 @@ void server<endpoint>::connection<connection_type>::write_response() {

m_endpoint.m_alog->at(log::alevel::DEBUG_HANDSHAKE) << raw << log::endl;

boost::asio::async_write( // FIXME
boost::asio::async_write(
m_connection.get_socket(),
//boost::asio::buffer(raw),
buffer,
Expand Down

0 comments on commit 405ccbc

Please sign in to comment.