C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::net::http Namespace Reference

Contains an implementation for HTTP. More...

Classes

struct  arg_parser
 Customization point for adding custom types to the <arg> parsing of the router. More...
 
class  async_client
 HTTP client for sending requests and receiving responses via promises. More...
 
class  client
 Implements the client part for the HTTP Protocol as defined in RFC 7231. More...
 
class  client_factory
 Factory for the with(...).connect(...).request(...) DSL. More...
 
class  header
 Encapsulates meta data for HTTP header fields. More...
 
class  lower_layer
 Parses HTTP requests and passes them to the upper layer. More...
 
class  request
 Implicitly shared handle type that represents an HTTP client request with a promise for the HTTP response. More...
 
class  request_header
 Encapsulates meta data for HTTP requests. More...
 
class  responder
 Responds to an HTTP request at the server. More...
 
class  response
 Handle type (implicitly shared) that represents an HTTP server response. More...
 
class  response_header
 Encapsulates meta data for HTTP response. More...
 
class  route
 Represents a single route for HTTP requests at a server. More...
 
class  router
 Sits on top of a server and dispatches incoming requests to user-defined handlers. More...
 
class  server
 Implements the server part for the HTTP Protocol as defined in RFC 7231. More...
 
class  server_factory
 Factory type for the with(...).accept(...).start(...) DSL. More...
 
class  upper_layer
 Operates on HTTP requests. More...
 
class  with_t
 Entry point for the with(...) DSL. More...
 

Typedefs

using route_ptr = intrusive_ptr<route>
 
template<class T >
using arg_parser_t = typename arg_parser_oracle<T>::type
 

Enumerations

enum class  method : uint8_t {
  get ,
  head ,
  post ,
  put ,
  del ,
  connect ,
  options ,
  trace
}
 Methods as defined by RFC 7231. More...
 
enum class  status : uint16_t {
  continue_request = 100 ,
  switching_protocols = 101 ,
  ok = 200 ,
  created = 201 ,
  accepted = 202 ,
  non_authoritative_information = 203 ,
  no_content = 204 ,
  reset_content = 205 ,
  partial_content = 206 ,
  multiple_choices = 300 ,
  moved_permanently = 301 ,
  found = 302 ,
  see_other = 303 ,
  not_modified = 304 ,
  use_proxy = 305 ,
  temporary_redirect = 307 ,
  bad_request = 400 ,
  unauthorized = 401 ,
  payment_required = 402 ,
  forbidden = 403 ,
  not_found = 404 ,
  method_not_allowed = 405 ,
  not_acceptable = 406 ,
  proxy_authentication_required = 407 ,
  request_timeout = 408 ,
  conflict = 409 ,
  gone = 410 ,
  length_required = 411 ,
  precondition_failed = 412 ,
  payload_too_large = 413 ,
  uri_too_long = 414 ,
  unsupported_media_type = 415 ,
  range_not_satisfiable = 416 ,
  expectation_failed = 417 ,
  upgrade_required = 426 ,
  precondition_required = 428 ,
  too_many_requests = 429 ,
  request_header_fields_too_large = 431 ,
  internal_server_error = 500 ,
  not_implemented = 501 ,
  bad_gateway = 502 ,
  service_unavailable = 503 ,
  gateway_timeout = 504 ,
  http_version_not_supported = 505 ,
  network_authentication_required = 511
}
 Status codes as defined by RFC 7231 and RFC 6585. More...
 

Functions

std::string_view to_rfc_string (method x) noexcept
 
template<class F >
expected< route_ptrmake_route (std::string path, std::optional< http::method > method, F f)
 Creates a route object from a function object.
 
template<class F >
expected< route_ptrmake_route (std::string path, F f)
 Convenience function for calling make_route(path, std::nullopt, f).
 
template<class F >
expected< route_ptrmake_route (F f)
 Creates a route that matches all paths.
 
std::string_view phrase (status code)
 
with_t with (actor_system &sys)
 
with_t with (multiplexer *mpx)
 

Detailed Description

Contains an implementation for HTTP.

Enumeration Type Documentation

◆ method

enum class caf::net::http::method : uint8_t
strong

Methods as defined by RFC 7231.

Enumerator
get 

Requests transfer of a current selected representation for the target resource.

head 

Identical to GET except that the server MUST NOT send a message body in the response.

The server SHOULD send the same header fields in response to a HEAD request as it would have sent if the request had been a GET, except that the payload header fields (Section 3.3) MAY be omitted.

post 

Requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics.

put 

Requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload.

del 

Requests that the origin server remove the association between the target resource and its current functionality.

connect 

Requests that the recipient establish a tunnel to the destination origin server identified by the request-target and, if successful, thereafter restrict its behavior to blind forwarding of packets, in both directions, until the tunnel is closed.

options 

Requests information about the communication options available for the target resource, at either the origin server or an intervening intermediary.

trace 

Requests a remote, application-level loop-back of the request message.

◆ status

enum class caf::net::http::status : uint16_t
strong

Status codes as defined by RFC 7231 and RFC 6585.

Enumerator
continue_request 

Indicates that the initial part of a request has been received and has not yet been rejected by the server.

The server intends to send a final response after the request has been fully received and acted upon.

switching_protocols 

Indicates that the server understands and is willing to comply with the client's request for a change in the application protocol being used on this connection.

ok 

Indicates that the request has succeeded.

created 

Indicates that the request has been fulfilled and has resulted in one or more new resources being created.

accepted 

Indicates that the request has been accepted for processing, but the processing has not been completed.

non_authoritative_information 

Indicates that the request was successful but the enclosed payload has been modified from that of the origin server's 200 (OK) response by a transforming proxy.

no_content 

Indicates that the server has successfully fulfilled the request and that there is no additional content to send in the response payload body.

reset_content 

Indicates that the server has fulfilled the request and desires that the user agent reset the "document view".

partial_content 

Indicates that the server is successfully fulfilling a range request for the target resource by transferring one or more parts of the selected representation that correspond to the satisfiable ranges found in the request's Range header field.

multiple_choices 

Indicates that the target resource has more than one representation and information about the alternatives is being provided so that the user (or user agent) can select a preferred representation.

moved_permanently 

Indicates that the target resource has been assigned a new permanent URI.

found 

Indicates that the target resource resides temporarily under a different URI.

see_other 

Indicates that the server is redirecting the user agent to a different resource, as indicated by a URI in the Location header field, which is intended to provide an indirect response to the original request.

not_modified 

Indicates that a conditional GET or HEAD request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition evaluated to false.

use_proxy 

Deprecated.

temporary_redirect 

No longer valid.

bad_request 

Indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

unauthorized 

Indicates that the request has not been applied because it lacks valid authentication credentials for the target resource.

payment_required 

Reserved for future use.

forbidden 

Indicates that the server understood the request but refuses to authorize it.

not_found 

Indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

method_not_allowed 

Indicates that the method received in the request-line is known by the origin server but not supported by the target resource.

not_acceptable 

Indicates that the target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request (Section 5.3), and the server is unwilling to supply a default representation.

proxy_authentication_required 

Similar to 401 (Unauthorized), but it indicates that the client needs to authenticate itself in order to use a proxy.

request_timeout 

Indicates that the server did not receive a complete request message within the time that it was prepared to wait.

conflict 

Indicates that the request could not be completed due to a conflict with the current state of the target resource.

This code is used in situations where the user might be able to resolve the conflict and resubmit the request.

gone 

Indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent.

length_required 

Indicates that the server refuses to accept the request without a defined Content-Length.

precondition_failed 

Indicates that one or more conditions given in the request header fields evaluated to false when tested on the server.

payload_too_large 

Indicates that the server is refusing to process a request because the request payload is larger than the server is willing or able to process.

uri_too_long 

Indicates that the server is refusing to service the request because the request-target is longer than the server is willing to interpret.

unsupported_media_type 

Indicates that the origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource.

range_not_satisfiable 

Indicates that none of the ranges in the request's Range header field overlap the current extent of the selected resource or that the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges.

expectation_failed 

Indicates that the expectation given in the request's Expect header field could not be met by at least one of the inbound servers.

upgrade_required 

Indicates that the server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.

precondition_required 

Indicates that the origin server requires the request to be conditional.

too_many_requests 

Indicates that the user has sent too many requests in a given amount of time ("rate limiting").

request_header_fields_too_large 

Indicates that the server is unwilling to process the request because its header fields are too large.

internal_server_error 

Indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

not_implemented 

Indicates that the server does not support the functionality required to fulfill the request.

bad_gateway 

Indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.

service_unavailable 

Indicates that the server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay.

gateway_timeout 

Indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.

http_version_not_supported 

Indicates that the server does not support, or refuses to support, the major version of HTTP that was used in the request message.

network_authentication_required 

Indicates that the client needs to authenticate to gain network access.

Function Documentation

◆ make_route()

template<class F >
expected< route_ptr > caf::net::http::make_route ( std::string path,
std::optional< http::method > method,
F f )

Creates a route object from a function object.

Parameters
pathDescription of the path, optionally with <arg> placeholders.
methodThe HTTP method for the path or std::nullopt for "any".
fThe callback for the path.
Returns
a path on success, an error when failing to parse the path or to match it to the signature of f.