diff --git a/include/fc/network/http/connection.hpp b/include/fc/network/http/connection.hpp index 5918c8a..974deb6 100644 --- a/include/fc/network/http/connection.hpp +++ b/include/fc/network/http/connection.hpp @@ -58,7 +58,7 @@ namespace fc { ~connection(); // used for clients void connect_to( const fc::ip::endpoint& ep ); - http::reply request( const fc::string& method, const fc::string& url, const fc::string& body, const headers& = headers()); + http::reply request( const fc::string& method, const fc::string& url, const fc::string& body = std::string(), const headers& = headers()); // used for servers fc::tcp_socket& get_socket()const; diff --git a/include/fc/network/tcp_socket.hpp b/include/fc/network/tcp_socket.hpp index b808f24..1a3bf2c 100644 --- a/include/fc/network/tcp_socket.hpp +++ b/include/fc/network/tcp_socket.hpp @@ -14,6 +14,11 @@ namespace fc { void connect_to( const fc::ip::endpoint& e ); fc::ip::endpoint remote_endpoint()const; + void get( char& c ) + { + read( &c, 1 ); + } + /// istream interface /// @{ virtual size_t readsome( char* buffer, size_t max ); diff --git a/src/network/http/http_connection.cpp b/src/network/http/http_connection.cpp index b283a2d..af0a91b 100644 --- a/src/network/http/http_connection.cpp +++ b/src/network/http/http_connection.cpp @@ -7,6 +7,7 @@ #include #include #include +#include class fc::http::connection::impl @@ -90,14 +91,15 @@ http::reply connection::request( const fc::string& method, const fc::string& url, const fc::string& body, const headers& he ) { + fc::url parsed_url(url); if( !my->sock.is_open() ) { wlog( "Re-open socket!" ); my->sock.connect_to( my->ep ); } try { fc::stringstream req; - req << method <<" "<generic_string()<<" HTTP/1.1\r\n"; + req << "Host: "<<*parsed_url.host()<<"\r\n"; req << "Content-Type: application/json\r\n"; for( auto i = he.begin(); i != he.end(); ++i ) { diff --git a/src/rpc/json_connection.cpp b/src/rpc/json_connection.cpp index 73feba7..0915f20 100644 --- a/src/rpc/json_connection.cpp +++ b/src/rpc/json_connection.cpp @@ -64,7 +64,7 @@ namespace fc { namespace rpc { void handle_message( const variant_object& obj ) { - // wlog( "recv: ${msg}", ("msg", obj) ); + wlog( "recv: ${msg}", ("msg", obj) ); try { auto m = obj.find("method");