Giter Club home page Giter Club logo

restbed's Introduction

Restbed Unix Build Status Windows Build Status


Restbed is a comprehensive and consistent programming model for building applications that require seamless and secure communication over HTTP, with the ability to model a range of business processes, designed to target mobile, tablet, desktop and embedded production environments.

It's akin to embedding NGINX into your companies own product line. -- Solutions Architect, Bellrock Technology

Features

Feature Description
WebSockets Full-duplex communication channels over a single TCP connection.
Server-Sent Events Server-Sent Events enables efficient server-to-client streaming of text-based event data—e.g., real-time notifications or updates generated on the server.
Comet Long polling model to allow long-held HTTP requests for pushing data from the server to client.
SSL/TLS Secure over the wire communication allowing you to transmit private data online.
Session Management Create custom HTTP session persistence and management logic.
HTTP Pipelining A technique allowing multiple HTTP requests to be sent on a single TCP connection without waiting for the corresponding responses.
Path Parameters Annotate URIs with custom path parameters such as resource keys, revisions, etc...
Query Parameters Automated query parameter parsing.
Header Filters Filter incoming HTTP requests by headers.
Logging Customise how and where log entries are created.
Multi-Path Resources Give a resource multiple paths for improved readability.
Customisable Methods Add your own custom HTTP methods.
Compression Adaptability to address any form of compression GZip, Deflate, etc...
Encoding Adaptability to address any form of encoding UTF-32, ASCII, etc...
Rules Engine Reduce complexity by processing incoming requests with readable units of code.
HTTP/HTTPS Built in client capabilities with optional SSL peer certificate verification. Deprecated
IPv4/IPv6 Internet Protocol Version 4/6 Network Support.
Architecture Asynchronous single or multi-threaded architecture, capable of addressing the C10K problem.
Converters Built-in Path, Query, and Header conversions for primary data-types.
Authentication Separate Service and/or Resource level authentication.
Error Handling Separate Service and/or Resource level error handling.
Address Binding Bind HTTP and/or HTTPS services to separate IP addresses.
Signal Handling Capture OS generated process signals.
Documentation High-quality documentation covering the architecture and API.
Compliance Flexibility to address HTTP 1.0/1.1+ compliance.
Mature Secure, Stable, and extensively tested since 2013.
Community Active, vibrant and energetic open source community.
Support Commercial support is available from Corvusoft.

Example

#include <memory>
#include <cstdlib>
#include <restbed>

using namespace std;
using namespace restbed;

void post_method_handler( const shared_ptr< Session > session )
{
    const auto request = session->get_request( );

    int content_length = request->get_header( "Content-Length", 0 );

    session->fetch( content_length, [ ]( const shared_ptr< Session > session, const Bytes & body )
    {
        fprintf( stdout, "%.*s\n", ( int ) body.size( ), body.data( ) );
        session->close( OK, "Hello, World!", { { "Content-Length", "13" } } );
    } );
}

int main( const int, const char** )
{
    auto resource = make_shared< Resource >( );
    resource->set_path( "/resource" );
    resource->set_method_handler( "POST", post_method_handler );

    auto settings = make_shared< Settings >( );
    settings->set_port( 1984 );
    settings->set_default_header( "Connection", "close" );

    Service service;
    service.publish( resource );
    service.start( settings );

    return EXIT_SUCCESS;
}

More in-depth examples can be found here. To see Restbed used in anger, please visit Corvusoft's RestQ project.

License

© 2013-2020 Corvusoft Limited, United Kingdom. All rights reserved.

The Restbed framework is dual licensed; See LICENSE for full details.

Support

Please contact [email protected], for support and licensing options including bespoke software development, testing, design consultation, training, mentoring and code review.

Please submit all enhancements, proposals, and defects via the issue tracker; Alternatively ask a question on StackOverflow tagged #restbed.

Build

git clone --recursive https://github.com/corvusoft/restbed.git
mkdir restbed/build
cd restbed/build
cmake [-DBUILD_SSL=NO] [-DBUILD_TESTS=NO] ..
make install
make test

You will now find all required components installed in the distribution sub-folder.

Building with external libraries

If you wish to build with external libraries (OpenSSL, ASIO).

git clone https://github.com/corvusoft/restbed.git
mkdir restbed/build
cd restbed/build
cmake [-DBUILD_SSL=NO] [-DBUILD_TESTS=NO] ..
make install
make test

Windows Build Instructions

For Microsoft Visual Studio instructions please see feature #17.

Building restbed - Using vcpkg

You can download and install restbed using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install restbed

The restbed port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Documentation

This codebase is intended to be as self documenting as possible. We have supplied many examples and test suites to help aid developers.

You can locate the latest design and API documentation here.

Minimum Requirements

Resource Requirement
Compiler C++14 compliant or above
OS BSD, Linux, Mac OSX, Windows, Raspbian

Road Map

Milestone Feature Status
0.0 Asynchronous HTTP Service complete
1.0 HTTP 1.0 Compliance complete
2.0 HTTP 1.1 Compliance complete
2.5 Secure Socket Layer complete
2.5 Simultaneous Network Ports (HTTP/HTTPS) complete
3.0 Rules Engine complete
3.5 Schedule Tasks on Service run-loop complete
3.5 Multi-Threaded service capability complete
3.5 Bind Service to specific Address complete
3.5 Session Management complete
4.0 HTTP Client complete
4.0 Signal Handling complete
4.5 API Documentation complete
4.5 Web Sockets complete
5.0 Client-side SSL certificates development
5.0 Resource Caching development
5.0 Runtime Modifications development
5.0 HTTP 2 compliance development
5.0 Refactor, Reduce, Reuse pending

Contact

Method Description
Twitter Tweet us your questions & feature requests.
[email protected] Support related queries.
[email protected] Sale related queries.

restbed's People

Contributors

aberaud avatar alf848 avatar amarok1412 avatar arthurafarias avatar aviau avatar axelsommerfeldt avatar bansan85 avatar ben-crowhurst avatar callum-kirby avatar clrusby avatar dev-masih avatar gitter-badger avatar ignitenet-martynas avatar juliusza avatar katemamba avatar mreierson avatar naedanger avatar nunojpg avatar okanon avatar pawan9 avatar pawani2v avatar pkubaj avatar sgammill avatar sotex avatar szotsaki avatar takashisasaki avatar tanmayambre avatar voldien avatar zmij avatar zzl-010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

restbed's Issues

Service dies randomly after a few hours

I've tried implementing your example code in an executable called m3 but it seems to die randomly after a few hours (when not being called upon over http). Here's the SIGSEV backtrace.

./m3(_Z7handleri+0x15)[0x430845]
/lib/x86_64-linux-gnu/libc.so.6(+0x35180)[0x7f5d2c65c180]
./m3(_ZN4asio3ssl6detail5io_opINS_19basic_stream_socketINS_2ip3tcpENS_21stream_socket_serviceIS5_EEEENS1_8write_opINS_15const_buffers_1EEENS_6detail8write_opINS0_6streamIS8_EESA_NSC_14transfer_all_tESt8functionIFvRKSt10error_codemEEEEEclESI_mi+0x138)[0x475ef8]
./m3(_ZN4asio6detail8write_opINS_3ssl6streamINS_19basic_stream_socketINS_2ip3tcpENS_21stream_socket_serviceIS6_EEEEEENS_15const_buffers_1ENS0_14transfer_all_tESt8functionIFvRKSt10error_codemEEEclESG_mi+0xea)[0x47656a]
./m3(_ZN7restbed6detail10SocketImpl5writeERKSt6vectorIhSaIhEERKSt8functionIFvRKSt10error_codemEE+0x13a)[0x472e5a]
./m3(_ZNK7restbed6detail11SessionImpl8transmitERKNS_8ResponseERKSt8functionIFvRKSt10error_codemEE+0x2aa)[0x46f7fa]
./m3(_ZN7restbed7Session5closeERKNS_8ResponseE+0x98)[0x46b4c8]
./m3(_ZN7restbed7Session5closeEiRKSt6vectorIhSaIhEERKSt8multimapISsSsSt4lessISsESaISt4pairIKSsSsEEE+0x48)[0x46c8e8]
./m3(_ZN7restbed7Session5closeEiRKSsRKSt8multimapISsSsSt4lessISsESaISt4pairIS1_SsEEE+0x2b)[0x46c9db]
./m3(_ZNK7restbed6detail11SessionImpl7failureESt10shared_ptrINS_7SessionEEiRKSt9exception+0x27b)[0x46e21b]

Resolve lack of build warnings.

When building on Ubuntu systems with -DBUILD_EXAMPLES the build fails if pthreads, PAM dev, OpenSSL dev, and/or syslog headers are not present. We should add checks to determine the state of the system before building.

Extend Session API with error handlers.

Brief
Give greater control over error path logic. As shown in the example below, supplying an error_handler will override any Service and/or Resource error handlers.

Example

void post_method_handler( const shared_ptr< Session >& session )
{
    const auto request = session->get_request( );

    size_t content_length = 0;
    request->get_header( "Content-Length", content_length );

    session->fetch( content_length, success_handler, error_handler );
}

int main( const int, const char** )
{
    auto resource = make_shared< Resource >( );
    resource->set_path( "/resource" );
    resource->set_method_handler( "POST", post_method_handler );

    auto settings = make_shared< Settings >( );
    settings->set_port( 1984 );
    settings->set_default_header( "Connection", "close" );

    Service service;
    service.publish( resource );
    service.start( settings );

    return EXIT_SUCCESS;
}

It's possible compile restbed with boost::asio ?

I have a large project which is already link with boost and boost::asio as static link, now I would like to integrate restbed into my project, but it's seems restbed is depends on non-boost::asio, it will causes the conflict unless I wrapper the restbed as dynamic link.

So my question is possible compile restbed with boost::asio ?

SSL build options and #ifdef, #else, #endif

During the development of the SSL feature a slew of #ifdef conditionals were placed in the codebase to allow optional compilation. This has resulted in an unreadable layout that has my OCD ringing.

How to compile restbed for x64 ?

The VS project which generated from CMAKE just include the 32bit project, I'm created the X64 project which copy from the x86, but got the compile error :

Error 2 error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' E:\Stacks\restbed\x64\Debug\uri.obj 1 1 restbed

Resource Caching

Allow a resource cache to be injected into the service. This cache would be consulted with the incoming request m_cache->find_entry( request ) to determine if we should call the method handler or throw back the cache entry.

Cache cache;

Service service;
service.set_cache( cache );

HTTP 2 Compliance

    auto settings = make_shared< Settings >( );

    Service service;
    service.add_application_layer(  http_10_instance );
    service.add_application_layer( http_11_instance );
    service.add_application_layer( http2_instance );
    service.add_application_layer(  spdy_instance );
    service.start( settings );

Show Request API some love.

            void get_query_parameter( const std::string& name,
                                      int& value, /*out*/
                                      const int default_value = 0,
                                      const bool ignore_case = true,
                                      const std::function< std::string ( const std::string& ) >& transform = nullptr ) const;


            void get_path_parameter( const std::string& name,
                                     unsigned int& value, /*out*/
                                     const unsigned int default_value = 0,
                                     const bool ignore_case = true,
                                     const std::function< std::string ( const std::string& ) >& transform = nullptr ) const;

Path parameters are case insensitive

URLs in general are case-sensitive (with the exception of machine names). There may be URLs, or parts of URLs, where case doesn't matter, but identifying these may not be easy. Users should always consider that URLs are case-sensitive.

reference

Add rules option for Resource::set_handler.

Resource resource;
resource.set_handler( "POST", rules, callback );

This can be useful/cleaner when creating rules that should only run for particular methods or deviate from the larger ruleset.

Session Management

The ability to store session data and retrieve it at a later date.

SessionManager manager;

Service service;
service.set_session_manager( manager );

WebSocket API Proposal.

auto request = session->get_request( );

if ( request.get_header( "connection", String::lowercase ) == "upgrade" )
{
    if ( request.get_header( "upgrade", String::lowercase ) == "websocket" )
    {
        //validate client headers.

        session->yield( SwitchingProtocols,  { response headers... }, [ ]( shared_ptr< WebSocket >& socket )
        {
            socket.on( "close", callback );
            socket.on( "error", callback );
            socket.on( "message", callback );
            socket.close( callback );
            socket.send( "", callback );
        }
    } //else...
}

Request

GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Origin: http://example.com
Server response:

Response

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: chat
http://stackoverflow.com/questions/17364318/asynchronously-waiting-until-a-socket-is-available-for-reading-writing-in-asio

API
http://enterprisewebbook.com/ch8_websockets.html
https://developer.mozilla.org/en-US/docs/WebSockets/Writing_WebSocket_servers
http://stackoverflow.com/questions/17364318/asynchronously-waiting-until-a-socket-is-available-for-reading-writing-in-asio

Review Test Coverage.

Currently due to the limitations of the framework::Http logic. We are unable to perform client-side HTTPS requests.

Multi-Threaded service capability

void get_method_handler( const shared_ptr< Session >& session )
{
    session->close( OK, "Hello, World!", { { "Content-Length", "13" }, { "Connection", "close" } } );
}

void service_ready_handler( Service& service )
{
    thread thread1( bind( &Service::start, service );
    thread thread2( bind( &Service::start, service );
   ...
}

int main( const int, const char** )
{
    auto resource = make_shared< Resource >( );
    resource->set_path( "/resource" );
    resource->set_method_handler( "GET", get_method_handler );

    auto settings = make_shared< Settings >( );
    settings->set_port( 1984 );

    auto service = make_shared< Service >( );
    service->publish( resource );
    service->set_ready_handler( service_ready_handler );
    service->start( settings );

    return EXIT_SUCCESS;
}

API
http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/io_service/run/overload2.html

Flexible session data storage.

Brief
Give sessions the ability to retain data between asynchronous calls. This should help aid readability and put a halt to std::bind( callback, this, MyCustomSessionContextContainer ).

Example

void get_method_handler( const shared_ptr< Session >& session )
{
  set< string > filters = { "age", "name" };
  session.set( "filters", filters );

  session->wait_for( chrono::seconds( 5 ), [ ]( const shared_ptr< Session >& session )
  {
    set< string > filters = session->get( "filters" );
 } );
}

int main( const int, const char** )
{
    auto resource = make_shared< Resource >( );
    resource->set_path( "/resources/item" );
    resource->set_method_handler( "GET", get_method_handler );

    auto settings = make_shared< Settings >( );
    settings->set_port( 1984 );
    settings->set_default_header( "Connection", "close" );

    Service service;
    service.publish( resource );
    service.start( settings );

    return EXIT_SUCCESS;
}

API

set< string > Session::keys( void ) const;

void erase( const std::string& name = "" );

bool Session::has( const std::string& name ) const;

const std::typeinfo Session::type( const std::string& name );

ContextValue Session::get( const std::string& name ) const;

ContextValue Session::get( const std::string& name, ContextValue default ) const;

void Session::set( const std::string& name, ContextValue );

transfer encoding chunked example for binary files

Hi,

Do you have an example of receiving binary files (such as jpeg images) via transfer encoding chunked. The example transfer_encoding_request shows sending text files, but when sending binary data is does not work.

Thanks.

Segmentation fault, when the client closes the session while the server is inside the callback

I have a server that a callback to a request takes a while. Meanwhile if the client closes the connection, I got a segmentation fault in the server. Here is the full backtrace

(gdb) bt
#0  0x000055555578bbd3 in asio::ssl::detail::engine::perform(int (asio::ssl::detail::engine::*)(void*, unsigned long), void*, unsigned long, std::error_code&, unsigned long*) ()
#1  0x000055555578ebde in asio::ssl::detail::io_op<asio::basic_stream_socket<asio::ip::tcp, asio::stream_socket_service<asio::ip::tcp> >, asio::ssl::detail::write_op<asio::const_buffers_1>, asio::detail::write_op<asio::ssl::stream<asio::basic_stream_socket<asio::ip::tcp, asio::stream_socket_service<asio::ip::tcp> > >, asio::const_buffers_1, asio::detail::transfer_all_t, std::function<void (std::error_code const&, unsigned long)> > >::operator()(std::error_code, unsigned long, int) ()
#2  0x000055555578f464 in asio::detail::write_op<asio::ssl::stream<asio::basic_stream_socket<asio::ip::tcp, asio::stream_socket_service<asio::ip::tcp> > >, asio::const_buffers_1, asio::detail::transfer_all_t, std::function<void (std::error_code const&, unsigned long)> >::operator()(std::error_code const&, unsigned long, int) ()
#3  0x000055555578b390 in restbed::detail::SocketImpl::write(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::function<void (std::error_code const&, unsigned long)> const&) ()
#4  0x00005555557874dc in restbed::detail::SessionImpl::transmit(restbed::Response const&, std::function<void (std::error_code const&, unsigned long)> const&) const ()
#5  0x0000555555781f47 in restbed::Session::close(restbed::Response const&) ()
#6  0x0000555555783fe3 in restbed::Session::close(int, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::multimap<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&) ()
#7  0x0000555555784146 in restbed::Session::close(int, std::string const&, std::multimap<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&) ()
#8  0x0000555555785a2d in restbed::detail::SessionImpl::failure(std::shared_ptr<restbed::Session>, int, std::exception const&) const ()
#9  0x0000555555780512 in std::_Function_handler<void (std::error_code const&, unsigned long), restbed::Session::close(restbed::Response const&)::{lambda(std::error_code const&, unsigned long)#1}>::_M_invoke(std::_Any_data const&, std::error_code const&, unsigned long&&) ()
#10 0x000055555578c2b7 in asio::detail::write_op<asio::basic_stream_socket<asio::ip::tcp, asio::stream_socket_service<asio::ip::tcp> >, asio::const_buffers_1, asio::detail::transfer_all_t, std::function<void (std::error_code const&, unsigned long)> >::operator()(std::error_code const&, unsigned long, int) ()
#11 0x000055555578c45e in asio::detail::reactive_socket_send_op<asio::const_buffers_1, asio::detail::write_op<asio::basic_stream_socket<asio::ip::tcp, asio::stream_socket_service<asio::ip::tcp> >, asio::const_buffers_1, asio::detail::transfer_all_t, std::function<void (std::error_code const&, unsigned long)> > >::do_complete(asio::detail::task_io_service*, asio::detail::task_io_service_operation*, std::error_code const&, unsigned long) ()
#12 0x0000555555752d0b in std::thread::_Impl<std::_Bind_simple<restbed::Service::start(std::shared_ptr<restbed::Settings const> const&)::{lambda()#2} ()> >::_M_run()
    ()
#13 0x00007ffff5411350 in std::(anonymous namespace)::execute_native_thread_routine (__p=<optimized out>)
    at /build/gcc-multilib/src/gcc-5.2.0/libstdc++-v3/src/c++11/thread.cc:84
#14 0x00007ffff5dd24a4 in start_thread () from /usr/lib/libpthread.so.0
#15 0x00007ffff4b8913d in clone () from /usr/lib/libc.so.6

Request style parsing for Settings properties.

void get_property( const std::string& name, int& value, const int default_value = 0 ) const;
void get_property( const std::string& name, long& value, const long default_value = 0 ) const;
void get_property( const std::string& name, float& value, const float default_value = 0 ) const;
void get_property( const std::string& name, double& value, const double default_value = 0 ) const;
void get_property( const std::string& name, long long& value, const long long default_value = 0 ) const;
void get_property( const std::string& name, unsigned int& value, const unsigned int default_value = 0 ) const;
void get_property( const std::string& name, unsigned long& value, const unsigned long default_value = 0 ) const;
void get_property( const std::string& name, unsigned long long& value, const unsigned long long default_value = 0 ) const;

Example

int timeout = 0;
settings.get_property( "timeout", timeout, 10 );

HTTP pipelining.

Originally it was decided not to implement this feature. However after some consideration it appears to be straight forward enough.

example request/response.

settings.set_pipelining_enabled( true ) );

Failing build when linking with OpenSSL

$ make
Linking CXX shared library librestbed.dylib
Undefined symbols for architecture x86_64:
"_ERR_remove_thread_state", referenced from:
asio::ssl::detail::openssl_init_base::do_init::~do_init() in service.cpp.o
asio::ssl::detail::openssl_init_base::do_init::~do_init() in service_impl.cpp.o
asio::ssl::detail::openssl_init_base::do_init::~do_init() in session.cpp.o
asio::ssl::detail::openssl_init_base::do_init::~do_init() in session_impl.cpp.o
asio::ssl::detail::openssl_init_base::do_init::~do_init() in socket_impl.cpp.o
"_TLSv1_1_client_method", referenced from:
asio::ssl::context::context(asio::ssl::context_base::method) in service_impl.cpp.o
"_TLSv1_1_method", referenced from:
asio::ssl::context::context(asio::ssl::context_base::method) in service_impl.cpp.o
"_TLSv1_1_server_method", referenced from:
asio::ssl::context::context(asio::ssl::context_base::method) in service_impl.cpp.o
"_TLSv1_2_client_method", referenced from:
asio::ssl::context::context(asio::ssl::context_base::method) in service_impl.cpp.o
"_TLSv1_2_method", referenced from:
asio::ssl::context::context(asio::ssl::context_base::method) in service_impl.cpp.o
"_TLSv1_2_server_method", referenced from:
asio::ssl::context::context(asio::ssl::context_base::method) in service_impl.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [librestbed.dylib] Error 1
make[1]: *** [CMakeFiles/restbed.dir/all] Error 2
make: *** [all] Error 2

Bind Service to specific Address

Settings settings;
settings.set_bind_address( "127.0.0.1" );

SSLSettings ssl_settings;
ssl_settings.set_bind_address( "198.2.0.1" );

Inaccurate parsing of headers.

This (^(.*): *(.*)\\s*$) does not look like correct headers handling, for instance try to parse User-Agent: Mozilla:4.0. Are you aware of RFC 7230 to speak about compliance?

OpenSSL depenency management.

Currently we don't pull down OpenSSL when cloning the repository. And we don't force the dependency to build if we fail to locate a preinstalled installation.

How should we manage this dependency?

  1. User instructions?
  2. CMake ExternalProject_Add?
  3. Other?

Improve build speed

Investigate parallel builds to increase project compilation time.

make -j5

Compiling with restbed

Hi,

I'm having some troubles compiling your library on linux mint 17.2.. I'm not an expert in C++, especially with third-party libraries..

My problem is that I try to compile with librestbed.so and it doesn't work.. I used your example and just changed #include <restbed> by #include </usr/local/lib/restbed/build/librestbed.so>.. (The restbed folder being in /usr/local/lib/)

Then, I compile the file example.cpp using the command: g++ -lx/usr/local/lib/restbed/build/librestbed.so example.cpp

If I do this, I get this error:
^ In file included from test.cpp:3:0: /usr/local/lib/restbed/build/librestbed.so:33:72: error: expected unqualified-id before ‘!’ token �0�Hm�n��״�ҿ���}�rm!����b���K��OOk6+����S�&��o͎���-?z��>%a0C�~�� ^ In file included from test.cpp:3:0: /usr/local/lib/restbed/build/librestbed.so:35:140: error: expected unqualified-id before ‘<’ token q� z,��Y��*4����S�/\(�|/��,�xo����C?�j��Jh��Fgv���.�Y�.�ڜ�-q͑�F6��0/�=ݳ��m}��3J:�'11��U�ܐ5�����U�Co�}��f��W�O������3�&�}�N��U6�e\����Y�S��v��}��7����Je���,f�j����$�̫�m��<.�1I�s�Z��u԰�&ә�k<F�� ^
Does anyone have any idea why??

Thanks for your answers

Linux build warnings.

The linux build has many warnings around ASIO. This is due to our use of -Wall -Wextra -Weffc++ -pedantic.

Expose asynchronous signal handling.

Example

Service service;
service.set_signal_handler( int signal, [ ]( void )
{

} );

Source

signal_handler_setup( asio::io_service& service, asio::signal_set& signals )
{
    signals.async_wait( [ &service, &signals ]( system::error_code error, int signal )
    {
        if ( not error )
       {
           std::cerr << "received signal " <<  signalNumber << std::endl;
           signal_handler_setup( service, signals );
       }
    } );
}

asio::io_service service;
asio::signal_set signals { service };
signals.add( SIGTERM );
signal_handler_setup( service, signals );
service.run( );

Acceptance Tests fail under Linux.

A random selection of acceptance tests fail when run all at once i.e make test. If you run each test case individually, everything thing is 5-by-5. It appears to be caused by service::start( ) and then service::stop( ) being called in close succession; Catch++ causing issues?

Further work is required to produce a workaround.

Using the framework is not hindered by this situation.

HTTP client capabilities.

struct Http::Request
{
      Bytes body;
      uint16_t port;
      string method;
      struct SSL { ... }
      ...
      std::future< Http::Response > response;
};

Http::sync( Http::Request request );
Http::sync( std::list< Http::Request >& requests );

Http::async( Http::Request request );
Http::async( std::list< Http::Request >& requests );

The async methods fire off as many requests as possible and return without blocking. It is then the responsibility of the developer to check each future for a ready response.

for ( auto request : requests )
{
    if ( request.response.wait_for( std::chrono::seconds( 0 ) ) == std::future_status::ready )
    {
        //process response.
    }
}

Further discussion is required around sharing the same asio::io_service as the restbed::Service or having a separate instance.

Can't compile with VS2013, UPDATE4

Does the restbed test with VS2013?

Error 1 error C2797: 'restbed::detail::SettingsImpl::m_status_messages': list initialization inside member initializer list or non-static data member initializer is not implemented E:\Stacks\restbed\source\corvusoft\restbed\detail\settings_impl.hpp 116 1 restbed

Error 2 error C2668: 'restbed::Session::close' : ambiguous call to overloaded function E:\Stacks\restbed\source\corvusoft\restbed\detail\service_impl.cpp 398 1 restbed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.