Add namespace around all files
This commit is contained in:
+14
-11
@@ -10,7 +10,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace http
|
||||
namespace osrm
|
||||
{
|
||||
namespace server
|
||||
{
|
||||
|
||||
Connection::Connection(boost::asio::io_service &io_service, RequestHandler &handler)
|
||||
@@ -38,14 +40,14 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
||||
}
|
||||
|
||||
// no error detected, let's parse the request
|
||||
compression_type compression_type(no_compression);
|
||||
osrm::tribool result;
|
||||
http::compression_type compression_type(http::no_compression);
|
||||
util::tribool result;
|
||||
std::tie(result, compression_type) =
|
||||
request_parser.parse(current_request, incoming_data_buffer.data(),
|
||||
incoming_data_buffer.data() + bytes_transferred);
|
||||
|
||||
// the request has been parsed
|
||||
if (result == osrm::tribool::yes)
|
||||
if (result == util::tribool::yes)
|
||||
{
|
||||
current_request.endpoint = TCP_socket.remote_endpoint().address();
|
||||
request_handler.handle_request(current_request, current_reply);
|
||||
@@ -56,7 +58,7 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
||||
// compress the result w/ gzip/deflate if requested
|
||||
switch (compression_type)
|
||||
{
|
||||
case deflate_rfc1951:
|
||||
case http::deflate_rfc1951:
|
||||
// use deflate for compression
|
||||
current_reply.headers.insert(current_reply.headers.begin(),
|
||||
{"Content-Encoding", "deflate"});
|
||||
@@ -65,7 +67,7 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
||||
output_buffer = current_reply.headers_to_buffers();
|
||||
output_buffer.push_back(boost::asio::buffer(compressed_output));
|
||||
break;
|
||||
case gzip_rfc1952:
|
||||
case http::gzip_rfc1952:
|
||||
// use gzip for compression
|
||||
current_reply.headers.insert(current_reply.headers.begin(),
|
||||
{"Content-Encoding", "gzip"});
|
||||
@@ -74,7 +76,7 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
||||
output_buffer = current_reply.headers_to_buffers();
|
||||
output_buffer.push_back(boost::asio::buffer(compressed_output));
|
||||
break;
|
||||
case no_compression:
|
||||
case http::no_compression:
|
||||
// don't use any compression
|
||||
current_reply.set_uncompressed_size();
|
||||
output_buffer = current_reply.to_buffers();
|
||||
@@ -86,9 +88,9 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
||||
strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(),
|
||||
boost::asio::placeholders::error)));
|
||||
}
|
||||
else if (result == osrm::tribool::no)
|
||||
else if (result == util::tribool::no)
|
||||
{ // request is not parseable
|
||||
current_reply = reply::stock_reply(reply::bad_request);
|
||||
current_reply = http::reply::stock_reply(http::reply::bad_request);
|
||||
|
||||
boost::asio::async_write(
|
||||
TCP_socket, current_reply.to_buffers(),
|
||||
@@ -118,14 +120,14 @@ void Connection::handle_write(const boost::system::error_code &error)
|
||||
}
|
||||
|
||||
std::vector<char> Connection::compress_buffers(const std::vector<char> &uncompressed_data,
|
||||
const compression_type compression_type)
|
||||
const http::compression_type compression_type)
|
||||
{
|
||||
boost::iostreams::gzip_params compression_parameters;
|
||||
|
||||
// there's a trade-off between speed and size. speed wins
|
||||
compression_parameters.level = boost::iostreams::zlib::best_speed;
|
||||
// check which compression flavor is used
|
||||
if (deflate_rfc1951 == compression_type)
|
||||
if (http::deflate_rfc1951 == compression_type)
|
||||
{
|
||||
compression_parameters.noheader = true;
|
||||
}
|
||||
@@ -141,3 +143,4 @@ std::vector<char> Connection::compress_buffers(const std::vector<char> &uncompre
|
||||
return compressed_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user