mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Remove unused HTTPRequest class
This commit is contained in:
@@ -2240,16 +2240,10 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\net\HTTPClient.h">
|
<ClInclude Include="..\..\src\ripple\net\HTTPClient.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\net\HTTPRequest.h">
|
|
||||||
</ClInclude>
|
|
||||||
<ClCompile Include="..\..\src\ripple\net\impl\HTTPClient.cpp">
|
<ClCompile Include="..\..\src\ripple\net\impl\HTTPClient.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\ripple\net\impl\HTTPRequest.cpp">
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\ripple\net\impl\InfoSub.cpp">
|
<ClCompile Include="..\..\src\ripple\net\impl\InfoSub.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
|
|||||||
@@ -2799,15 +2799,9 @@
|
|||||||
<ClInclude Include="..\..\src\ripple\net\HTTPClient.h">
|
<ClInclude Include="..\..\src\ripple\net\HTTPClient.h">
|
||||||
<Filter>ripple\net</Filter>
|
<Filter>ripple\net</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\net\HTTPRequest.h">
|
|
||||||
<Filter>ripple\net</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClCompile Include="..\..\src\ripple\net\impl\HTTPClient.cpp">
|
<ClCompile Include="..\..\src\ripple\net\impl\HTTPClient.cpp">
|
||||||
<Filter>ripple\net\impl</Filter>
|
<Filter>ripple\net\impl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\ripple\net\impl\HTTPRequest.cpp">
|
|
||||||
<Filter>ripple\net\impl</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\ripple\net\impl\InfoSub.cpp">
|
<ClCompile Include="..\..\src\ripple\net\impl\InfoSub.cpp">
|
||||||
<Filter>ripple\net\impl</Filter>
|
<Filter>ripple\net\impl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@@ -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 <boost/asio/streambuf.hpp>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
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<std::string, std::string>& 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<std::string, std::string> mHeaders;
|
|
||||||
|
|
||||||
int iDataSize;
|
|
||||||
bool bShouldClose;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -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 <BeastConfig.h>
|
|
||||||
#include <ripple/net/HTTPRequest.h>
|
|
||||||
#include <beast/module/core/text/LexicalCast.h>
|
|
||||||
#include <boost/algorithm/string.hpp>
|
|
||||||
#include <boost/format.hpp>
|
|
||||||
#include <istream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
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 <int> (headerValue);
|
|
||||||
|
|
||||||
if (headerName == "authorization")
|
|
||||||
sAuthorization = headerValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return haREAD_LINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert (false);
|
|
||||||
return haERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // ripple
|
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER /**/
|
#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER /**/
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/net/impl/HTTPRequest.cpp>
|
|
||||||
#include <ripple/net/impl/HTTPClient.cpp>
|
#include <ripple/net/impl/HTTPClient.cpp>
|
||||||
#include <ripple/net/impl/InfoSub.cpp>
|
#include <ripple/net/impl/InfoSub.cpp>
|
||||||
#include <ripple/net/impl/RPCCall.cpp>
|
#include <ripple/net/impl/RPCCall.cpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user