Merge branch 'phoenix' of https://github.com/InvictusInnovations/fc into phoenix
This commit is contained in:
commit
0dffdeb975
4 changed files with 11 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <fc/crypto/hex.hpp>
|
||||
#include <fc/log/logger.hpp>
|
||||
#include <fc/io/stdio.hpp>
|
||||
#include <fc/network/url.hpp>
|
||||
|
||||
|
||||
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 <<" "<<url<<" HTTP/1.1\r\n";
|
||||
req << "Host: localhost\r\n";
|
||||
req << method <<" "<<parsed_url.path()->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 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue