Skip to content

Commit

Permalink
All boost::shared_ptr typedefs are now passed to functions by const ref.
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Williamson committed Jul 13, 2015
1 parent 5d99f90 commit 6425c64
Show file tree
Hide file tree
Showing 36 changed files with 122 additions and 122 deletions.
2 changes: 1 addition & 1 deletion include/pion/http/auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PION_API auth :
*
* @return true if request valid and user identity inserted into request
*/
virtual bool handle_request(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn) = 0;
virtual bool handle_request(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn) = 0;

/**
* sets a configuration option
Expand Down
4 changes: 2 additions & 2 deletions include/pion/http/basic_auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PION_API basic_auth :
*
* @return true if request valid and user identity inserted into request
*/
virtual bool handle_request(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn);
virtual bool handle_request(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn);

/**
* sets a configuration option
Expand All @@ -67,7 +67,7 @@ class PION_API basic_auth :
* @param http_request_ptr the new HTTP request to handle
* @param tcp_conn the TCP connection that has the new request
*/
void handle_unauthorized(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn);
void handle_unauthorized(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn);

/**
* extracts base64 user credentials from authorization string
Expand Down
10 changes: 5 additions & 5 deletions include/pion/http/cookie_auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PION_API cookie_auth :
*
* @return true if request valid and user identity inserted into request
*/
virtual bool handle_request(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn);
virtual bool handle_request(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn);

/**
* sets a configuration option
Expand Down Expand Up @@ -94,23 +94,23 @@ class PION_API cookie_auth :
*
* @return true if it was a login/logout request and no future processing required.
*/
bool process_login(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn);
bool process_login(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn);

/**
* used to send responses when access to resource is not authorized
*
* @param http_request_ptr the new HTTP request to handle
* @param tcp_conn the TCP connection that has the new request
*/
void handle_unauthorized(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn);
void handle_unauthorized(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn);

/**
* used to send redirection responses
*
* @param http_request_ptr the new HTTP request to handle
* @param tcp_conn the TCP connection that has the new request
*/
void handle_redirection(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn,
void handle_redirection(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn,
const std::string &redirection_url, const std::string &new_cookie="", bool delete_cookie=false);

/**
Expand All @@ -119,7 +119,7 @@ class PION_API cookie_auth :
* @param http_request_ptr the new HTTP request to handle
* @param tcp_conn the TCP connection that has the new request
*/
void handle_ok(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn,
void handle_ok(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn,
const std::string &new_cookie="", bool delete_cookie=false);

/**
Expand Down
2 changes: 1 addition & 1 deletion include/pion/http/plugin_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class plugin_service :
* @param http_request_ptr the new HTTP request to handle
* @param tcp_conn the TCP connection that has the new request
*/
virtual void operator()(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn) = 0;
virtual void operator()(const http::request_ptr& http_request_ptr, const tcp::connection_ptr& tcp_conn) = 0;

/**
* sets a configuration option
Expand Down
2 changes: 1 addition & 1 deletion include/pion/http/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PION_API reader :
* if false, the message is parsed as an HTTP response
* @param tcp_conn TCP connection containing a new message to parse
*/
reader(const bool is_request, tcp::connection_ptr& tcp_conn)
reader(const bool is_request, const tcp::connection_ptr& tcp_conn)
: http::parser(is_request), m_tcp_conn(tcp_conn),
m_read_timeout(DEFAULT_READ_TIMEOUT)
{}
Expand Down
4 changes: 2 additions & 2 deletions include/pion/http/request_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class request_reader :
* @param handler function called after the message has been parsed
*/
static inline boost::shared_ptr<request_reader>
create(tcp::connection_ptr& tcp_conn, finished_handler_t handler)
create(const tcp::connection_ptr& tcp_conn, finished_handler_t handler)
{
return boost::shared_ptr<request_reader>
(new request_reader(tcp_conn, handler));
Expand All @@ -68,7 +68,7 @@ class request_reader :
* @param tcp_conn TCP connection containing a new message to parse
* @param handler function called after the message has been parsed
*/
request_reader(tcp::connection_ptr& tcp_conn, finished_handler_t handler)
request_reader(const tcp::connection_ptr& tcp_conn, finished_handler_t handler)
: http::reader(true, tcp_conn), m_http_msg(new http::request),
m_finished(handler)
{
Expand Down
10 changes: 5 additions & 5 deletions include/pion/http/request_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class request_writer :
* @return boost::shared_ptr<request_writer> shared pointer to
* the new writer object that was created
*/
static inline boost::shared_ptr<request_writer> create(tcp::connection_ptr& tcp_conn,
static inline boost::shared_ptr<request_writer> create(const tcp::connection_ptr& tcp_conn,
finished_handler_t handler = finished_handler_t())
{
return boost::shared_ptr<request_writer>(new request_writer(tcp_conn, handler));
Expand All @@ -61,8 +61,8 @@ class request_writer :
* @return boost::shared_ptr<request_writer> shared pointer to
* the new writer object that was created
*/
static inline boost::shared_ptr<request_writer> create(tcp::connection_ptr& tcp_conn,
http::request_ptr& http_request_ptr,
static inline boost::shared_ptr<request_writer> create(const tcp::connection_ptr& tcp_conn,
const http::request_ptr& http_request_ptr,
finished_handler_t handler = finished_handler_t())
{
return boost::shared_ptr<request_writer>(new request_writer(tcp_conn, http_request_ptr, handler));
Expand All @@ -80,7 +80,7 @@ class request_writer :
* @param tcp_conn TCP connection used to send the request
* @param handler function called after the request has been sent
*/
request_writer(tcp::connection_ptr& tcp_conn, finished_handler_t handler)
request_writer(const tcp::connection_ptr& tcp_conn, finished_handler_t handler)
: http::writer(tcp_conn, handler), m_http_request(new http::request)
{
set_logger(PION_GET_LOGGER("pion.http.request_writer"));
Expand All @@ -93,7 +93,7 @@ class request_writer :
* @param http_request_ptr pointer to the request that will be sent
* @param handler function called after the request has been sent
*/
request_writer(tcp::connection_ptr& tcp_conn, http::request_ptr& http_request_ptr,
request_writer(const tcp::connection_ptr& tcp_conn, const http::request_ptr& http_request_ptr,
finished_handler_t handler)
: http::writer(tcp_conn, handler), m_http_request(http_request_ptr)
{
Expand Down
4 changes: 2 additions & 2 deletions include/pion/http/response_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class response_reader :
* @param handler function called after the message has been parsed
*/
static inline boost::shared_ptr<response_reader>
create(tcp::connection_ptr& tcp_conn, const http::request& http_request,
create(const tcp::connection_ptr& tcp_conn, const http::request& http_request,
finished_handler_t handler)
{
return boost::shared_ptr<response_reader>
Expand All @@ -71,7 +71,7 @@ class response_reader :
* @param http_request the request we are responding to
* @param handler function called after the message has been parsed
*/
response_reader(tcp::connection_ptr& tcp_conn, const http::request& http_request,
response_reader(const tcp::connection_ptr& tcp_conn, const http::request& http_request,
finished_handler_t handler)
: http::reader(false, tcp_conn), m_http_msg(new http::response(http_request)),
m_finished(handler)
Expand Down
10 changes: 5 additions & 5 deletions include/pion/http/response_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class PION_API response_writer :
* @return boost::shared_ptr<response_writer> shared pointer to
* the new writer object that was created
*/
static inline boost::shared_ptr<response_writer> create(tcp::connection_ptr& tcp_conn,
http::response_ptr& http_response_ptr,
static inline boost::shared_ptr<response_writer> create(const tcp::connection_ptr& tcp_conn,
const http::response_ptr& http_response_ptr,
finished_handler_t handler = finished_handler_t())
{
return boost::shared_ptr<response_writer>(new response_writer(tcp_conn, http_response_ptr, handler));
Expand All @@ -64,7 +64,7 @@ class PION_API response_writer :
* @return boost::shared_ptr<response_writer> shared pointer to
* the new writer object that was created
*/
static inline boost::shared_ptr<response_writer> create(tcp::connection_ptr& tcp_conn,
static inline boost::shared_ptr<response_writer> create(const tcp::connection_ptr& tcp_conn,
const http::request& http_request,
finished_handler_t handler = finished_handler_t())
{
Expand All @@ -84,7 +84,7 @@ class PION_API response_writer :
* @param http_response pointer to the response that will be sent
* @param handler function called after the request has been sent
*/
response_writer(tcp::connection_ptr& tcp_conn, http::response_ptr& http_response_ptr,
response_writer(const tcp::connection_ptr& tcp_conn, const http::response_ptr& http_response_ptr,
finished_handler_t handler)
: http::writer(tcp_conn, handler), m_http_response(http_response_ptr)
{
Expand All @@ -108,7 +108,7 @@ class PION_API response_writer :
* @param http_request the request we are responding to
* @param handler function called after the request has been sent
*/
response_writer(tcp::connection_ptr& tcp_conn, const http::request& http_request,
response_writer(const tcp::connection_ptr& tcp_conn, const http::request& http_request,
finished_handler_t handler)
: http::writer(tcp_conn, handler), m_http_response(new http::response(http_request))
{
Expand Down
30 changes: 15 additions & 15 deletions include/pion/http/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class PION_API server :
public:

/// type of function that is used to handle requests
typedef boost::function2<void, http::request_ptr&, tcp::connection_ptr&> request_handler_t;
typedef boost::function2<void, const http::request_ptr&, const tcp::connection_ptr&> request_handler_t;

/// handler for requests that result in "500 Server Error"
typedef boost::function3<void, http::request_ptr&, tcp::connection_ptr&,
typedef boost::function3<void, const http::request_ptr&, const tcp::connection_ptr&,
const std::string&> error_handler_t;


Expand Down Expand Up @@ -170,17 +170,17 @@ class PION_API server :
* @param http_request_ptr the new HTTP request to handle
* @param tcp_conn the TCP connection that has the new request
*/
static void handle_bad_request(http::request_ptr& http_request_ptr,
tcp::connection_ptr& tcp_conn);
static void handle_bad_request(const http::request_ptr& http_request_ptr,
const tcp::connection_ptr& tcp_conn);

/**
* used to send responses when no web services can handle the request
*
* @param http_request_ptr the new HTTP request to handle
* @param tcp_conn the TCP connection that has the new request
*/
static void handle_not_found_request(http::request_ptr& http_request_ptr,
tcp::connection_ptr& tcp_conn);
static void handle_not_found_request(const http::request_ptr& http_request_ptr,
const tcp::connection_ptr& tcp_conn);

/**
* used to send responses when a server error occurs
Expand All @@ -189,8 +189,8 @@ class PION_API server :
* @param tcp_conn the TCP connection that has the new request
* @param error_msg message that explains what went wrong
*/
static void handle_server_error(http::request_ptr& http_request_ptr,
tcp::connection_ptr& tcp_conn,
static void handle_server_error(const http::request_ptr& http_request_ptr,
const tcp::connection_ptr& tcp_conn,
const std::string& error_msg);

/**
Expand All @@ -200,8 +200,8 @@ class PION_API server :
* @param tcp_conn the TCP connection that has the new request
* @param error_msg message that explains what went wrong
*/
static void handle_forbidden_request(http::request_ptr& http_request_ptr,
tcp::connection_ptr& tcp_conn,
static void handle_forbidden_request(const http::request_ptr& http_request_ptr,
const tcp::connection_ptr& tcp_conn,
const std::string& error_msg);

/**
Expand All @@ -211,8 +211,8 @@ class PION_API server :
* @param tcp_conn the TCP connection that has the new request
* @param allowed_methods optional comma separated list of allowed methods
*/
static void handle_method_not_allowed(http::request_ptr& http_request_ptr,
tcp::connection_ptr& tcp_conn,
static void handle_method_not_allowed(const http::request_ptr& http_request_ptr,
const tcp::connection_ptr& tcp_conn,
const std::string& allowed_methods = "");

/**
Expand All @@ -230,7 +230,7 @@ class PION_API server :
*
* @param tcp_conn the new TCP connection to handle
*/
virtual void handle_connection(tcp::connection_ptr& tcp_conn);
virtual void handle_connection(const tcp::connection_ptr& tcp_conn);

/**
* handles a new HTTP request
Expand All @@ -239,8 +239,8 @@ class PION_API server :
* @param tcp_conn TCP connection containing a new request
* @param ec error_code contains additional information for parsing errors
*/
virtual void handle_request(http::request_ptr& http_request_ptr,
tcp::connection_ptr& tcp_conn, const boost::system::error_code& ec);
virtual void handle_request(const http::request_ptr& http_request_ptr,
const tcp::connection_ptr& tcp_conn, const boost::system::error_code& ec);

/**
* searches for the appropriate request handler to use for a given resource
Expand Down
2 changes: 1 addition & 1 deletion include/pion/http/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PION_API writer :
* @param tcp_conn TCP connection used to send the message
* @param handler function called after the request has been sent
*/
writer(tcp::connection_ptr& tcp_conn, finished_handler_t handler)
writer(const tcp::connection_ptr& tcp_conn, finished_handler_t handler)
: m_logger(PION_GET_LOGGER("pion.http.writer")),
m_tcp_conn(tcp_conn), m_content_length(0), m_stream_is_empty(true),
m_client_supports_chunks(true), m_sending_chunks(false),
Expand Down
6 changes: 3 additions & 3 deletions include/pion/spdy/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PION_API parser
*/
boost::tribool parse(http_protocol_info& http_headers,
boost::system::error_code& ec,
decompressor_ptr& decompressor,
const decompressor_ptr& decompressor,
const char *packet_ptr,
boost::uint32_t& length_packet,
boost::uint32_t current_stream_count);
Expand Down Expand Up @@ -155,7 +155,7 @@ class PION_API parser
*
*/
void parse_header_payload(boost::system::error_code& ec,
decompressor_ptr& decompressor,
const decompressor_ptr& decompressor,
const spdy_control_frame_info& frame,
http_protocol_info& http_headers,
boost::uint32_t current_stream_count);
Expand Down Expand Up @@ -213,7 +213,7 @@ class PION_API parser
* indeterminate = not yet finished parsing SPDY frame
*/
boost::tribool parse_spdy_frame(boost::system::error_code& ec,
decompressor_ptr& decompressor,
const decompressor_ptr& decompressor,
http_protocol_info& http_headers,
boost::uint32_t& length_packet,
boost::uint32_t current_stream_count);
Expand Down
8 changes: 4 additions & 4 deletions include/pion/tcp/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class PION_API server :
*
* @param tcp_conn the new TCP connection to handle
*/
virtual void handle_connection(tcp::connection_ptr& tcp_conn) {
virtual void handle_connection(const tcp::connection_ptr& tcp_conn) {
tcp_conn->set_lifecycle(connection::LIFECYCLE_CLOSE); // make sure it will get closed
tcp_conn->finish();
}
Expand Down Expand Up @@ -174,7 +174,7 @@ class PION_API server :
* @param tcp_conn the new TCP connection (if no error occurred)
* @param accept_error true if an error occurred while accepting connections
*/
void handle_accept(tcp::connection_ptr& tcp_conn,
void handle_accept(const tcp::connection_ptr& tcp_conn,
const boost::system::error_code& accept_error);

/**
Expand All @@ -183,14 +183,14 @@ class PION_API server :
* @param tcp_conn the new TCP connection (if no error occurred)
* @param handshake_error true if an error occurred during the SSL handshake
*/
void handle_ssl_handshake(tcp::connection_ptr& tcp_conn,
void handle_ssl_handshake(const tcp::connection_ptr& tcp_conn,
const boost::system::error_code& handshake_error);

/// This will be called by connection::finish() after a server has
/// finished handling a connection. If the keep_alive flag is true,
/// it will call handle_connection(); otherwise, it will close the
/// connection and remove it from the server's management pool
void finish_connection(tcp::connection_ptr& tcp_conn);
void finish_connection(const tcp::connection_ptr& tcp_conn);

/// prunes orphaned connections that did not close cleanly
/// and returns the remaining number of connections in the pool
Expand Down
4 changes: 2 additions & 2 deletions include/pion/tcp/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class stream_buffer
*
* @param conn_ptr pointer to the TCP connection to use for reading & writing
*/
explicit stream_buffer(tcp::connection_ptr& conn_ptr)
explicit stream_buffer(const tcp::connection_ptr& conn_ptr)
: m_conn_ptr(conn_ptr), m_read_buf(m_conn_ptr->get_read_buffer().c_array())
{
setup_buffers();
Expand Down Expand Up @@ -338,7 +338,7 @@ class stream
*
* @param conn_ptr pointer to the TCP connection to use for reading & writing
*/
explicit stream(tcp::connection_ptr& conn_ptr)
explicit stream(const tcp::connection_ptr& conn_ptr)
: std::basic_iostream<char, std::char_traits<char> >(NULL), m_tcp_buf(conn_ptr)
{
// initialize basic_iostream with pointer to the stream buffer
Expand Down
2 changes: 1 addition & 1 deletion include/pion/tcp/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PION_API timer
*
* @param conn_ptr pointer to TCP connection to monitor
*/
timer(tcp::connection_ptr& conn_ptr);
timer(const tcp::connection_ptr& conn_ptr);

/**
* starts a timer for closing a TCP connection
Expand Down
Loading

0 comments on commit 6425c64

Please sign in to comment.