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();
|
~connection();
|
||||||
// used for clients
|
// used for clients
|
||||||
void connect_to( const fc::ip::endpoint& ep );
|
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
|
// used for servers
|
||||||
fc::tcp_socket& get_socket()const;
|
fc::tcp_socket& get_socket()const;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ namespace fc {
|
||||||
void connect_to( const fc::ip::endpoint& e );
|
void connect_to( const fc::ip::endpoint& e );
|
||||||
fc::ip::endpoint remote_endpoint()const;
|
fc::ip::endpoint remote_endpoint()const;
|
||||||
|
|
||||||
|
void get( char& c )
|
||||||
|
{
|
||||||
|
read( &c, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
/// istream interface
|
/// istream interface
|
||||||
/// @{
|
/// @{
|
||||||
virtual size_t readsome( char* buffer, size_t max );
|
virtual size_t readsome( char* buffer, size_t max );
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <fc/crypto/hex.hpp>
|
#include <fc/crypto/hex.hpp>
|
||||||
#include <fc/log/logger.hpp>
|
#include <fc/log/logger.hpp>
|
||||||
#include <fc/io/stdio.hpp>
|
#include <fc/io/stdio.hpp>
|
||||||
|
#include <fc/network/url.hpp>
|
||||||
|
|
||||||
|
|
||||||
class fc::http::connection::impl
|
class fc::http::connection::impl
|
||||||
|
|
@ -90,14 +91,15 @@ http::reply connection::request( const fc::string& method,
|
||||||
const fc::string& url,
|
const fc::string& url,
|
||||||
const fc::string& body, const headers& he ) {
|
const fc::string& body, const headers& he ) {
|
||||||
|
|
||||||
|
fc::url parsed_url(url);
|
||||||
if( !my->sock.is_open() ) {
|
if( !my->sock.is_open() ) {
|
||||||
wlog( "Re-open socket!" );
|
wlog( "Re-open socket!" );
|
||||||
my->sock.connect_to( my->ep );
|
my->sock.connect_to( my->ep );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fc::stringstream req;
|
fc::stringstream req;
|
||||||
req << method <<" "<<url<<" HTTP/1.1\r\n";
|
req << method <<" "<<parsed_url.path()->generic_string()<<" HTTP/1.1\r\n";
|
||||||
req << "Host: localhost\r\n";
|
req << "Host: "<<*parsed_url.host()<<"\r\n";
|
||||||
req << "Content-Type: application/json\r\n";
|
req << "Content-Type: application/json\r\n";
|
||||||
for( auto i = he.begin(); i != he.end(); ++i )
|
for( auto i = he.begin(); i != he.end(); ++i )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace fc { namespace rpc {
|
||||||
|
|
||||||
void handle_message( const variant_object& obj )
|
void handle_message( const variant_object& obj )
|
||||||
{
|
{
|
||||||
// wlog( "recv: ${msg}", ("msg", obj) );
|
wlog( "recv: ${msg}", ("msg", obj) );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto m = obj.find("method");
|
auto m = obj.find("method");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue