Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP client capabilities. #41

Closed
ben-crowhurst opened this issue Sep 23, 2015 · 3 comments
Closed

HTTP client capabilities. #41

ben-crowhurst opened this issue Sep 23, 2015 · 3 comments
Assignees
Milestone

Comments

@ben-crowhurst
Copy link
Member

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.

@ben-crowhurst ben-crowhurst added this to the 4.0 milestone Sep 23, 2015
@ben-crowhurst
Copy link
Member Author

A customer has stated:

In our case, calling off the same asio::io_service probably wouldn't be an issue initially, however I could imagine cases where you might want to not do that.

@ben-crowhurst
Copy link
Member Author

struct Http::Request
{
      bool async;
      ...
      std::future< Http::Response > response;
};

Placing HTTP requests on the service run-loop.

service.schedule( Http::Request request, const function< void ( Http::Request ) >& callback );
service.schedule( list< Http::Request > request,  const function< void ( Http::Request ) >& callback );

Placing HTTP requests on its own run-loop

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

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

@ben-crowhurst
Copy link
Member Author

Placing HTTP requests on the service run-loop

service.schedule( Http::Request request, const function< void ( Http::Request ) >& callback );
service.schedule( list< Http::Request > request,  const function< void ( Http::Request ) >& callback );

Placing HTTP requests on its own run-loop

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

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

Perform SSL requests

SSLSetting settings;

Request request;
request.set_protocol( "HTTPS", settings );

Http::sync( request );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant