diff --git a/include/frnetlib/Http.h b/include/frnetlib/Http.h index 4aecd7d..6bd0715 100644 --- a/include/frnetlib/Http.h +++ b/include/frnetlib/Http.h @@ -315,6 +315,29 @@ namespace fr return type; } + /*! + * Overridable send, to allow + * custom types to be directly sent through + * sockets. + * + * @param socket The socket to send through + * @return Status indicating if the send succeeded or not. + */ + Socket::Status send(Socket *socket) const override; + + /*! + * Overrideable receive, to allow + * custom types to be directly received through + * sockets. + * + * @param socket The socket to send through + * @return Status indicating if the send succeeded or not: + * 'Success': All good, object still valid. + * 'WouldBlock' or 'Timeout': No data received. Object still valid though. + * Anything else: Object invalid. Call disconnect(). + */ + Socket::Status receive(Socket *socket) override; + protected: /*! * Splits a string by new line. Ignores escaped \n's @@ -340,28 +363,7 @@ namespace fr */ void parse_header_line(const std::string &str); - /*! - * Overridable send, to allow - * custom types to be directly sent through - * sockets. - * - * @param socket The socket to send through - * @return Status indicating if the send succeeded or not. - */ - Socket::Status send(Socket *socket) const override; - /*! - * Overrideable receive, to allow - * custom types to be directly received through - * sockets. - * - * @param socket The socket to send through - * @return Status indicating if the send succeeded or not: - * 'Success': All good, object still valid. - * 'WouldBlock' or 'Timeout': No data received. Object still valid though. - * Anything else: Object invalid. Call disconnect(). - */ - Socket::Status receive(Socket *socket) override; //Other request info std::unordered_map header_data; diff --git a/include/frnetlib/Packet.h b/include/frnetlib/Packet.h index 274913b..501b799 100644 --- a/include/frnetlib/Packet.h +++ b/include/frnetlib/Packet.h @@ -690,9 +690,6 @@ namespace fr return buffer.size() <= PACKET_HEADER_LENGTH ? 0 : buffer.size() - PACKET_HEADER_LENGTH; } - private: - friend class Socket; - /*! * Overridable send, to allow * custom types to be directly sent through @@ -748,10 +745,13 @@ namespace fr status = socket->receive_all(&buffer[PACKET_HEADER_LENGTH], packet_length); } while(status == fr::Socket::Status::WouldBlock); if(status == fr::Socket::Status::Timeout) - status = fr::Socket::Status::Disconnected; + status = fr::Socket::Status::Disconnected; return status; } + private: + friend class Socket; + mutable std::string buffer; //Packet data buffer size_t buffer_read_index; //Current read position diff --git a/include/frnetlib/WebFrame.h b/include/frnetlib/WebFrame.h index cc073d0..1209273 100644 --- a/include/frnetlib/WebFrame.h +++ b/include/frnetlib/WebFrame.h @@ -94,7 +94,6 @@ namespace fr final = is_final; } - protected: /*! * Overridable send, to allow * custom types to be directly sent through