From bfbfe2b052cd17f7df46fc30bfd307aba0341d36 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Tue, 18 Nov 2014 07:13:34 -0500 Subject: [PATCH] Clean up code style and STL includes --- test/http/parser.cpp | 1 + websocketpp/error.hpp | 2 ++ websocketpp/frame.hpp | 1 + websocketpp/http/constants.hpp | 2 ++ websocketpp/http/impl/parser.hpp | 1 + websocketpp/http/impl/request.hpp | 10 ++++++---- websocketpp/http/impl/response.hpp | 10 ++++++---- websocketpp/http/parser.hpp | 4 +++- websocketpp/http/request.hpp | 15 +++++++++------ websocketpp/http/response.hpp | 6 +++--- 10 files changed, 34 insertions(+), 18 deletions(-) diff --git a/test/http/parser.cpp b/test/http/parser.cpp index d8a551a..0200a1a 100644 --- a/test/http/parser.cpp +++ b/test/http/parser.cpp @@ -28,6 +28,7 @@ #define BOOST_TEST_MODULE http_parser #include +#include #include #include diff --git a/websocketpp/error.hpp b/websocketpp/error.hpp index 6fff530..a032e22 100644 --- a/websocketpp/error.hpp +++ b/websocketpp/error.hpp @@ -28,7 +28,9 @@ #ifndef WEBSOCKETPP_ERROR_HPP #define WEBSOCKETPP_ERROR_HPP +#include #include +#include #include #include diff --git a/websocketpp/frame.hpp b/websocketpp/frame.hpp index c22d358..8a17337 100644 --- a/websocketpp/frame.hpp +++ b/websocketpp/frame.hpp @@ -29,6 +29,7 @@ #define WEBSOCKETPP_FRAME_HPP #include +#include #include #include diff --git a/websocketpp/http/constants.hpp b/websocketpp/http/constants.hpp index 22af5f2..6d50c2d 100644 --- a/websocketpp/http/constants.hpp +++ b/websocketpp/http/constants.hpp @@ -28,9 +28,11 @@ #ifndef HTTP_CONSTANTS_HPP #define HTTP_CONSTANTS_HPP +#include #include #include #include +#include namespace websocketpp { /// HTTP handling support diff --git a/websocketpp/http/impl/parser.hpp b/websocketpp/http/impl/parser.hpp index a8f8d66..d34d55b 100644 --- a/websocketpp/http/impl/parser.hpp +++ b/websocketpp/http/impl/parser.hpp @@ -29,6 +29,7 @@ #define HTTP_PARSER_IMPL_HPP #include +#include #include #include diff --git a/websocketpp/http/impl/request.hpp b/websocketpp/http/impl/request.hpp index 57d8c55..380d4b4 100644 --- a/websocketpp/http/impl/request.hpp +++ b/websocketpp/http/impl/request.hpp @@ -29,7 +29,9 @@ #define HTTP_PARSER_REQUEST_IMPL_HPP #include +#include #include +#include #include @@ -37,7 +39,7 @@ namespace websocketpp { namespace http { namespace parser { -inline bool request::parse_complete(std::istream& s) { +inline bool request::parse_complete(std::istream & s) { std::string req; // get status line @@ -64,7 +66,7 @@ inline bool request::parse_complete(std::istream& s) { return parse_headers(s); } -inline size_t request::consume(const char *buf, size_t len) { +inline size_t request::consume(char const * buf, size_t len) { if (m_ready) {return 0;} if (m_buf->size() + len > max_header_size) { @@ -141,7 +143,7 @@ inline std::string request::raw() const { return ret.str(); } -inline void request::set_method(const std::string& method) { +inline void request::set_method(std::string const & method) { if (std::find_if(method.begin(),method.end(),is_not_token_char) != method.end()) { throw exception("Invalid method token.",status_code::bad_request); } @@ -156,7 +158,7 @@ inline void request::set_method(const std::string& method) { * * @param value The value to set the body to. */ -inline void request::set_uri(const std::string& uri) { +inline void request::set_uri(std::string const & uri) { // TODO: validation? m_uri = uri; } diff --git a/websocketpp/http/impl/response.hpp b/websocketpp/http/impl/response.hpp index 6a99e81..147147d 100644 --- a/websocketpp/http/impl/response.hpp +++ b/websocketpp/http/impl/response.hpp @@ -29,7 +29,9 @@ #define HTTP_PARSER_RESPONSE_IMPL_HPP #include +#include #include +#include #include @@ -37,7 +39,7 @@ namespace websocketpp { namespace http { namespace parser { -inline size_t response::consume(const char *buf, size_t len) { +inline size_t response::consume(char const * buf, size_t len) { if (m_state == DONE) {return 0;} if (m_state == BODY) { @@ -170,7 +172,7 @@ inline size_t response::consume(std::istream & s) { return total; } -inline bool response::parse_complete(std::istream& s) { +inline bool response::parse_complete(std::istream & s) { // parse a complete header (ie \r\n\r\n MUST be in the input stream) std::string line; @@ -217,7 +219,7 @@ inline void response::set_status(status_code::value code) { m_status_msg = get_string(code); } -inline void response::set_status(status_code::value code, const std::string& +inline void response::set_status(status_code::value code, std::string const & msg) { // TODO: validation? @@ -255,7 +257,7 @@ inline void response::process(std::string::iterator begin, set_status(status_code::value(code),std::string(cursor_end+1,end)); } -inline size_t response::process_body(const char *buf, size_t len) { +inline size_t response::process_body(char const * buf, size_t len) { // If no content length was set then we read forever and never set m_ready if (m_read == 0) { //m_body.append(buf,len); diff --git a/websocketpp/http/parser.hpp b/websocketpp/http/parser.hpp index cc81f63..24988a8 100644 --- a/websocketpp/http/parser.hpp +++ b/websocketpp/http/parser.hpp @@ -29,8 +29,10 @@ #define HTTP_PARSER_HPP #include -#include +#include #include +#include +#include #include #include diff --git a/websocketpp/http/request.hpp b/websocketpp/http/request.hpp index 0a95d36..bd0f3cf 100644 --- a/websocketpp/http/request.hpp +++ b/websocketpp/http/request.hpp @@ -28,6 +28,9 @@ #ifndef HTTP_PARSER_REQUEST_HPP #define HTTP_PARSER_REQUEST_HPP +#include +#include + #include #include @@ -55,7 +58,7 @@ public: , m_ready(false) {} /// DEPRECATED parse a complete header (\r\n\r\n MUST be in the istream) - bool parse_complete(std::istream& s); + bool parse_complete(std::istream & s); /// Process bytes in the input buffer /** @@ -77,7 +80,7 @@ public: * @param len Size of byte buffer * @return Number of bytes processed. */ - size_t consume(const char *buf, size_t len); + size_t consume(char const * buf, size_t len); /// Returns whether or not the request is ready for reading. bool ready() const { @@ -88,18 +91,18 @@ public: std::string raw() const; /// Set the HTTP method. Must be a valid HTTP token - void set_method(const std::string& method); + void set_method(std::string const & method); /// Return the request method - const std::string& get_method() const { + std::string const & get_method() const { return m_method; } /// Set the HTTP uri. Must be a valid HTTP uri - void set_uri(const std::string& uri); + void set_uri(std::string const & uri); /// Return the requested URI - const std::string& get_uri() const { + std::string const & get_uri() const { return m_uri; } diff --git a/websocketpp/http/response.hpp b/websocketpp/http/response.hpp index 3825a55..84d525f 100644 --- a/websocketpp/http/response.hpp +++ b/websocketpp/http/response.hpp @@ -82,7 +82,7 @@ public: * @param len Size of byte buffer * @return Number of bytes processed. */ - size_t consume(const char *buf, size_t len); + size_t consume(char const * buf, size_t len); size_t consume(std::istream & s); @@ -126,7 +126,7 @@ public: * @param code Code to set * @param msg Message to set */ - void set_status(status_code::value code, const std::string& msg); + void set_status(status_code::value code, std::string const & msg); /// Return the response status code status_code::value get_status_code() const { @@ -142,7 +142,7 @@ private: void process(std::string::iterator begin, std::string::iterator end); /// Helper function for processing body bytes - size_t process_body(const char *buf, size_t len); + size_t process_body(char const * buf, size_t len); enum state { RESPONSE_LINE = 0,