From aa5098866cf3181e4f1f427ed762c6552d925945 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Thu, 31 Mar 2016 19:22:14 -0700 Subject: [PATCH] Remove unused HTTPRequest class --- Builds/VisualStudio2015/RippleD.vcxproj | 6 - .../VisualStudio2015/RippleD.vcxproj.filters | 6 - src/ripple/net/HTTPRequest.h | 110 --------------- src/ripple/net/impl/HTTPRequest.cpp | 133 ------------------ src/ripple/unity/net.cpp | 1 - 5 files changed, 256 deletions(-) delete mode 100644 src/ripple/net/HTTPRequest.h delete mode 100644 src/ripple/net/impl/HTTPRequest.cpp diff --git a/Builds/VisualStudio2015/RippleD.vcxproj b/Builds/VisualStudio2015/RippleD.vcxproj index f0421428f..af0f8292e 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj +++ b/Builds/VisualStudio2015/RippleD.vcxproj @@ -2240,16 +2240,10 @@ - - True True - - True - True - True True diff --git a/Builds/VisualStudio2015/RippleD.vcxproj.filters b/Builds/VisualStudio2015/RippleD.vcxproj.filters index 57d342bbe..83a00dc49 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2015/RippleD.vcxproj.filters @@ -2799,15 +2799,9 @@ ripple\net - - ripple\net - ripple\net\impl - - ripple\net\impl - ripple\net\impl diff --git a/src/ripple/net/HTTPRequest.h b/src/ripple/net/HTTPRequest.h deleted file mode 100644 index 3e8d3e281..000000000 --- a/src/ripple/net/HTTPRequest.h +++ /dev/null @@ -1,110 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_NET_HTTPREQUEST_H_INCLUDED -#define RIPPLE_NET_HTTPREQUEST_H_INCLUDED - -#include -#include -#include - -namespace ripple { - -/** An HTTP request we are handling from a client. */ -class HTTPRequest -{ -public: - enum Action - { - // What the application code needs to do - haERROR = 0, - haREAD_LINE = 1, - haREAD_RAW = 2, - haDO_REQUEST = 3, - haCLOSE_CONN = 4 - }; - - HTTPRequest () : eState (await_request), iDataSize (0), bShouldClose (true) - { - ; - } - void reset (); - - std::string& peekBody () - { - return sRequestBody; - } - std::string getBody () - { - return sRequestBody; - } - std::string& peekRequest () - { - return sRequest; - } - std::string getRequest () - { - return sRequest; - } - std::string& peekAuth () - { - return sAuthorization; - } - std::string getAuth () - { - return sAuthorization; - } - - std::map& peekHeaders () - { - return mHeaders; - } - std::string getReplyHeaders (bool forceClose); - - Action consume (boost::asio::streambuf&); - Action requestDone (bool forceClose); // call after reply is sent - - int getDataSize () - { - return iDataSize; - } - -private: - enum state - { - await_request, // We are waiting for the request line - await_header, // We are waiting for request headers - getting_body, // We are waiting for the body - do_request, // We are waiting for the request to complete - }; - - state eState; - std::string sRequest; // VERB URL PROTO - std::string sRequestBody; - std::string sAuthorization; - - std::map mHeaders; - - int iDataSize; - bool bShouldClose; -}; - -} - -#endif diff --git a/src/ripple/net/impl/HTTPRequest.cpp b/src/ripple/net/impl/HTTPRequest.cpp deleted file mode 100644 index f763917f5..000000000 --- a/src/ripple/net/impl/HTTPRequest.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include -#include -#include - -namespace ripple { - -// Logic to handle incoming HTTP reqests - -void HTTPRequest::reset () -{ - mHeaders.clear (); - sRequestBody.clear (); - sAuthorization.clear (); - iDataSize = 0; - bShouldClose = true; - eState = await_request; -} - -HTTPRequest::Action HTTPRequest::requestDone (bool forceClose) -{ - if (forceClose || bShouldClose) - return haCLOSE_CONN; - - reset (); - return haREAD_LINE; -} - -std::string HTTPRequest::getReplyHeaders (bool forceClose) -{ - if (forceClose || bShouldClose) - return "Connection: close\r\n"; - else - return "Connection: Keep-Alive\r\n"; -} - -HTTPRequest::Action HTTPRequest::consume (boost::asio::streambuf& buf) -{ - std::string line; - std::istream is (&buf); - std::getline (is, line); - boost::trim (line); - - if (eState == await_request) - { - // VERB URL PROTO - if (line.empty ()) - return haREAD_LINE; - - sRequest = line; - bShouldClose = sRequest.find ("HTTP/1.1") == std::string::npos; - - eState = await_header; - return haREAD_LINE; - } - - if (eState == await_header) - { - // HEADER_NAME: HEADER_BODY - if (line.empty ()) // empty line or bare \r - { - if (iDataSize == 0) - { - // no body - eState = do_request; - return haDO_REQUEST; - } - - eState = getting_body; - return haREAD_RAW; - } - - size_t colon = line.find (':'); - - if (colon != std::string::npos) - { - std::string headerName = line.substr (0, colon); - boost::trim (headerName); - boost::to_lower (headerName); - - std::string headerValue = line.substr (colon + 1); - boost::trim (headerValue); - - mHeaders[headerName] += headerValue; - - if (headerName == "connection") - { - boost::to_lower (headerValue); - - if ((headerValue == "keep-alive") || (headerValue == "keepalive")) - bShouldClose = false; - - if (headerValue == "close") - bShouldClose = true; - } - - if (headerName == "content-length") - iDataSize = beast::lexicalCastThrow (headerValue); - - if (headerName == "authorization") - sAuthorization = headerValue; - } - - return haREAD_LINE; - } - - assert (false); - return haERROR; -} - -} // ripple diff --git a/src/ripple/unity/net.cpp b/src/ripple/unity/net.cpp index e4fd1e336..7c57f957c 100644 --- a/src/ripple/unity/net.cpp +++ b/src/ripple/unity/net.cpp @@ -21,7 +21,6 @@ #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER /**/ #include -#include #include #include #include