diff --git a/newcoin.vcxproj b/newcoin.vcxproj
index 9b2eec6ec3..8580bf2788 100644
--- a/newcoin.vcxproj
+++ b/newcoin.vcxproj
@@ -122,6 +122,7 @@
+
diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters
index ba656a48f4..fb793f90d5 100644
--- a/newcoin.vcxproj.filters
+++ b/newcoin.vcxproj.filters
@@ -243,6 +243,9 @@
Source Files
+
+ Source Files
+
diff --git a/src/CallRPC.cpp b/src/CallRPC.cpp
index dc2dbe8ee7..f12acaede6 100644
--- a/src/CallRPC.cpp
+++ b/src/CallRPC.cpp
@@ -145,6 +145,7 @@ Json::Value callRPC(const std::string& strMethod, const Json::Value& params)
throw std::runtime_error("no response from server");
// Parse reply
+ std::cout << "RPC reply: " << strReply << std::endl;
Json::Reader reader;
Json::Value valReply;
if (!reader.parse(strReply, valReply))
diff --git a/src/RPCDoor.cpp b/src/RPCDoor.cpp
index f12f52e77d..4234d79677 100644
--- a/src/RPCDoor.cpp
+++ b/src/RPCDoor.cpp
@@ -11,7 +11,7 @@ using namespace boost::asio::ip;
RPCDoor::RPCDoor(boost::asio::io_service& io_service) :
mAcceptor(io_service, tcp::endpoint(address::from_string(theConfig.RPC_IP), theConfig.RPC_PORT))
{
- cerr << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << endl;
+ cerr << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE << endl;
startListening();
}
diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp
index 624bb67198..f126154d02 100644
--- a/src/RPCServer.cpp
+++ b/src/RPCServer.cpp
@@ -61,6 +61,7 @@ void RPCServer::handle_read(const boost::system::error_code& e,
if (result)
{
mReplyStr=handleRequest(mIncomingRequest.mBody);
+
sendReply();
}
else if (!result)
@@ -2043,13 +2044,29 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
void RPCServer::sendReply()
{
+ std::cout << "RPC reply: " << mReplyStr << std::endl;
boost::asio::async_write(mSocket, boost::asio::buffer(mReplyStr),
boost::bind(&RPCServer::handle_write, shared_from_this(),
boost::asio::placeholders::error));
}
-void RPCServer::handle_write(const boost::system::error_code& /*error*/)
+
+
+void RPCServer::handle_write(const boost::system::error_code& e)
{
+ std::cout << "async_write complete " << e << std::endl;
+
+ if(!e)
+ {
+ // Initiate graceful connection closure.
+ boost::system::error_code ignored_ec;
+ mSocket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec);
+ }
+
+ if (e != boost::asio::error::operation_aborted)
+ {
+ //connection_manager_.stop(shared_from_this());
+ }
}
// vim:ts=4
diff --git a/src/rpc.cpp b/src/rpc.cpp
index e15d955f0e..a3180ed026 100644
--- a/src/rpc.cpp
+++ b/src/rpc.cpp
@@ -96,21 +96,27 @@ std::string HTTPReply(int nStatus, const std::string& strMsg)
else if (nStatus == 403) strStatus = "Forbidden";
else if (nStatus == 404) strStatus = "Not Found";
else if (nStatus == 500) strStatus = "Internal Server Error";
+ std::string access;
+ if(theConfig.RPC_ALLOW_REMOTE) access="Access-Control-Allow-Origin: *\r\n";
+ else access="";
+
return strprintf(
"HTTP/1.1 %d %s\r\n"
"Date: %s\r\n"
- "Connection: close\r\n"
+ "Connection: Keep-Alive\r\n"
+ "%s"
"Content-Length: %d\r\n"
- "Content-Type: application/json\r\n"
+ "Content-Type: application/json; charset=UTF-8\r\n"
"Server: coin-json-rpc/%s\r\n"
"\r\n"
"%s",
nStatus,
strStatus.c_str(),
rfc1123Time().c_str(),
+ access.c_str(),
strMsg.size(),
theConfig.VERSION_STR.c_str(),
- strMsg.c_str());
+ strMsg.c_str());
}
int ReadHTTPStatus(std::basic_istream& stream)